local chests = {
[COLOR="red"][1001] = { -- CHEST ACTION ID[/COLOR]
level = 100,
msg = "You have found some money!",
storage = 23315,
items = {
{2160,1},
{2152,1}
}
},
[COLOR="red"][1002] = { -- CHEST ACTION ID[/COLOR]
level = 100,
msg = "You have found some money!",
storage = 23315,
items = {
{2160,1},
{2152,1}
}
}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local v = chests[item.actionid]
if(getPlayerStorageValue(cid, v.storage) == -1) then
if(getPlayerLevel(cid) >= v.level) then
for i = 1, #v.items do
local x = v.items[i]
local rewards = doCreateItemEx(x[1], x[2] or 1)
if(doPlayerAddItemEx(cid, rewards, true) ~= RETURNVALUE_NOERROR) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You are unable to carry your reward.")
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, v.msg)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
setPlayerStorageValue(cid, v.storage, 1)
end
end
else
doPlayerSendCancel(cid, "Your level is not high enough.")
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
end
else
doPlayerSendCancel(cid, "The chest is empty.")
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
end
return true
end