tenta assim!
function onUse(cid, item, frompos, item2, topos)
local requiredCapacity = 360001.42 -- Minimum inventory capacity in oz
local chestUID = 1624
if item.uid == chestUID then
if getPlayerStorageValue(cid, chestUID) == -1 then
if getPlayerLevel(cid) >= 0 then
-- Check if the player has enough space in the inventory
if getPlayerFreeCap(cid) < requiredCapacity then
doPlayerSendCancel(cid, "You need at least 360001.42 oz of free capacity to use this chest.")
return true
end
-- Add backpacks with ID 10518 to the player's inventory
for i = 1, 42 do
if not doPlayerAddItem(cid, 10518, 1) then
doPlayerSendCancel(cid, "You don't have enough space for the backpacks.")
return true
end
end
-- Add 1,000,000 coins (ID 6527) inside a backpack (ID 10518) and repeat 100 times
for i = 1, 100 do
local backpack = doCreateItemEx(10518, 1)
if backpack ~= 0 then
for j = 1, 42 do
doAddContainerItem(backpack, 6527, 100)
end
doPlayerAddItemEx(cid, backpack, false)
else
doPlayerSendCancel(cid, "You don't have enough space for the backpacks.")
return true
end
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have won a prize.")
setPlayerStorageValue(cid, chestUID, 1)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need to be level 0 to use this chest.")
end
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have already received the bonus from this chest.")
end
end
return true
end