Code:
-- Code structured by ***MatheusMkalo***, Emky, and Unlimited
function onUse(cid, item, fromPosition, itemEx, toPosition)
local unique = 9500 --Unique ID
local quest = 9500 --Usually same as unique or action.. but I added space for univerial creation
local action = 0 --Action ID
local bp = 1987 -- Backpack or bag id
local reward = 2175
local rewardAmount = 1
local reward2 = 2145
local reward2Amount = 2
local reward3 = 2148
local reward3Amount = 100
local rewardContainer = 1740 --something like chest(1740), box(1741 or other), or dead human(2317)
if item.uid == (unique) then
queststatus = getPlayerStorageValue(cid,quest)
if queststatus == -1 then
local item = doCreateItemEx(bp, 1)
item_uid = doAddContainerItem(bag, reward, rewardAmount)
item_uid = doAddContainerItem(bag, reward2, reward2Amount)
item_uid = doAddContainerItem(bag, reward3, reward3Amount)
if item then
local ret = doPlayerAddItemEx(cid, item, false)
if ret == RETURNVALUE_NOERROR then
setPlayerStorageValue(cid,quest, 1)
doPlayerSendTextMessage(cid,22,"You have found a " .. getItemNameById(bp, 1) .. ".")
elseif ret == RETURNVALUE_NOTENOUGHCAPACITY then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You have found a reward weighing " .. getItemWeightById(bp) + (getItemWeightById(reward) * rewardAmount) + (getItemWeightById(reward2) * reward2Amount) + (getItemWeightById(reward3) * reward3Amount) .. " oz. It is too heavy.")
elseif ret == RETURNVALUE_NOTENOUGHROOM or ret == RETURNVALUE_CONTAINERNOTENOUGHROOM then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, 'You do not have enough space.')
else
doPlayerSendDefaultCancel(cid, ret)
end
end
else
doPlayerSendTextMessage(cid,22,"The " .. getItemNameById(rewardContainer) .. " is empty.")
end
end
return true
end
This is the part that's tossing the error.
Code:
local item = doCreateItemEx(bp, 1)
item_uid = doAddContainerItem(bag, reward, rewardAmount)
item_uid = doAddContainerItem(bag, reward2, reward2Amount)
item_uid = doAddContainerItem(bag, reward3, reward3Amount)
I'm trying to attempt to put these items INTO this container then give it to the player, which will do one of three things. Give it to them, toss a cap error, or toss a space error.
Problem is, I can't get the multiple items in a container to work correctly at all. I'm just getting a empty bag.
Thanks guys!