-- lets use a table so we can learn a little bit about how they work :)
local c = {
{id = 1987, amount = 1}, -- index 1, bag
{id = 2462, amount = 1},
{id = 2476, amount = 1},
{id = 2477, amount = 1},
{id = 2528, amount = 1},
{id = 2392, amount = 1}, -- index 6
questStorage = 12345, -- ipairs will ignore this
useThisItem = 1740, -- ipairs will ignore this
msg = "it is empty." -- ipairs will ignore this
}
function onUse(cid, item, frompos, item2, topos)
if item.itemid == c.useThisItem then -- item you use
if getPlayerStorageValue(cid, c.questStorage) < 1 then
setPlayerStorageValue(cid, c.questStorage, 1)
local bag = doPlayerAddItem(cid, c.[1].id, c.[1].amount)
table.remove(c, 1) -- remove bag from the table
c.msg = 'You have recieved '
for _, equipment in ipairs(c) do
doAddContainerItem(bag, equipment.id, equipment.amount)
c.msg = c.msg .. ' a ' .. getItemDescriptionsById(equipment.id).name .. ', '
end
c.msg = string.sub(c.msg, 1, string.len(c.msg)-1) .. ' as your reward!'
end
end
doPlayerSendTextMessage(cid, 22, c.msg)
return true
end