function onUse(cid, item, fromPosition, itemEx, toPosition)
local chests = {
[10000] = {
items = { {2160,10},{2152,10} },
container = 1988,
storage = 5511,
msg = "You have found a bag full of items."
},
[10001] = {
items = { {2160,10},{2152,10} },
container = 1988,
storage = 5511,
msg = "You have found a bag full of items."
},
[10002] = {
items = { {2160,10},{2152,10} },
container = 1988,
storage = 5511,
msg = "You have found a bag full of items."
}
}
local bp = doCreateItemEx(chests[item.uid].container, 1)
for i = 1, getContainerCapById(chests[item.uid].container) do
doAddContainerItem(bp, chests[item.uid].items[1], chests[item.uid].items[2])
end
if(doPlayerAddItemEx(cid, bp, 0) == RETURNVALUE_NOERROR) then
if(getPlayerStorageValue(cid, chests[item.uid].storage) == -1) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, chests[item.uid].msg)
setPlayerStorageValue(cid, chests[item.uid].storage, 1)
else
doPlayerSendCancel(cid, "You have already received your reward.")
end
else
doPlayerSendCancel(cid, "You do not have enough capacity/space.")
end
return true
end