Hi Players in my server Staff/Players they are all crashing everytime they use a chest for a quest can you please help me fix it?
Example of quest they are all the same except for items
Example of quest they are all the same except for items
Code:
local storage = 4022
local items = {
[1] = {item_id = 2491, item_count = 1},
[2] = {item_id = 2493, item_count = 1},
[3] = {item_id = 2414, item_count = 1}
}
local magicEffect = 25 --Magic effect for script--
local BAG_ID = 1987 --Set to bag they get for items--
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerStorageValue(cid, storage) == 1 then
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return doPlayerSendCancel(cid, "It is empty.")
end
local weight = 0
for i = 1, #items do
weight = weight + getItemWeightById(items[i].item_id)
end
local playerCap = getPlayerFreeCap(cid)
if playerCap >= weight then
local BAG = doPlayerAddItem(cid, BAG_ID, 1)
setPlayerStorageValue(cid, storage, 1)
doSendMagicEffect(getPlayerPosition(cid), magicEffect)
for i = 1, #items do
doAddContainerItem(BAG, items[i].item_id, items[i].item_count)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_GREEN, "You have found a "..getItemNameById(items[i].item_id)..".")
end
else
return doPlayerSendCancel(cid, "You require "..weight.." capacity to obtain this reward.")
end
return true
end