kite28
Member
- Joined
- May 15, 2012
- Messages
- 69
- Reaction score
- 5
I would like the console to not throw an error after using the item, can anyone help me?
Code:
local items = {
{itemId = 13432, count = 1, chance = 10}, -- ITEM, QUANTIDADE, CHANCE
{itemId = 13433, count = 1, chance = 10},
{itemId = 13434, count = 1, chance = 10},
{itemId = 13435, count = 1, chance = 10},
{itemId = 13436, count = 1, chance = 10},
{itemId = 13437, count = 1, chance = 10},
{itemId = 13444, count = 1, chance = 10},
}
local broadcastitems = {13432, 13433, 13434, 13435, 13436, 13437, 13444}
function onUse(cid, item, frompos, item2, topos)
local config = {
pos = getCreaturePosition(cid), -- posição do player
exhaustionSeconds = 3600, -- exausted em segundos
storageUse = 44231, -- storage usado.
}
if(exhaustion.check(cid, config.storageUse)) then
if (exhaustion.get(cid, config.storageUse) >= 60) then
doPlayerSendCancel(cid, "You can only open the chest again in " .. math.floor(exhaustion.get(cid, config.storageUse) / 60 + 1) .." minutes.")
end
if (exhaustion.get(cid, config.storageUse) <= 60) then
doPlayerSendCancel(cid, "You need to wait " .. exhaustion.get(cid, config.storageUse).." seconds.")
end
return true
end
local totalChance, randomTable, randomNumber = 0, {}, 0
addEvent(doPlayerSendTextMessage, 1*1000, cid, 27, "Wait...")
addEvent(doPlayerSendTextMessage, 2*1000, cid, 27, "Wait...")
addEvent(doPlayerSendTextMessage, 3*1000, cid, 27, "Wait...")
addEvent(doPlayerSendTextMessage, 4*1000, cid, 27, "Wait...")
addEvent(doPlayerSendTextMessage, 5*1000, cid, 27, "Wait...")
addEvent(doSendAnimatedText, 1*1000, config.pos, "[5]", 180)
addEvent(doSendAnimatedText, 2*1000, config.pos, "[4]", 180)
addEvent(doSendAnimatedText, 3*1000, config.pos, "[3]", 180)
addEvent(doSendAnimatedText, 4*1000, config.pos, "[2]", 180)
addEvent(doSendAnimatedText, 5*1000, config.pos, "[1]", 180)
addEvent(doSendAnimatedText, 6*1000, config.pos, "DONE!", 180)
for _, itemInfo in pairs (items) do
randomTable[itemInfo.itemId] = {min = totalChance + 1, max = itemInfo.chance, count = itemInfo.count or 1}
totalChance = totalChance + itemInfo.chance
end
randomNumber = math.random(1, totalChance)
for itemId, itemInfo in pairs (randomTable) do
local min, max = itemInfo.min, itemInfo.min + itemInfo.max
if randomNumber >= min and randomNumber <= max then
local newItem = addEvent(doPlayerAddItem, 6*1000, cid, itemId, itemInfo.count, false)
if not newItem then return doPlayerSendCancel(cid, "You do not have space to receive the item!") end
doRemoveItem(item.uid, 0)
exhaustion.set(cid, config.storageUse, config.exhaustionSeconds)
local iInfo = getItemInfo(itemId)
addEvent(doPlayerSendTextMessage, 6*1000, cid, 27, "You found ("..iInfo.name..")!")
for i, broaditem in ipairs(broadcastitems) do
if itemId==broaditem then addEvent(doBroadcastMessage, 6*1000, getCreatureName(cid).." just won: "..iInfo.name..".") end
doRemoveItem(13452, 1)
end
break
end
end
return true
end
Lua:
[11:28:26.731] [Error - Action Interface]
[11:28:26.731] data/actions/scripts/rare.lua:onUse
[11:28:26.732] Description:
[11:28:26.732] (LuaInterface::luaDoRemoveItem) Item not found