local config = {
rewards = {{2160, 100}, {2152, 50}},
level = 50,
messages = {
'You have found something interessing inside this chest.',
'Seems like you have already opened this chest.'
},
storage = 1337
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if(getPlayerLevel(cid) < config.level) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have to be at least '.. config.level ..' level to open this chest.')
return true
end
if(getCreatureStorage(cid, config.storage) ~= EMPTY_STORAGE) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, config.messages[2])
return true
end
for _, item in ipairs(config.rewards) do
doPlayerAddItem(cid, item[1], item[2])
end
doCreatureSetStorage(cid, config.storage, 1)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, config.messages[1])
return true
end