darkmu
Well-Known Member
This is my code, but.. when the player is promoted him not recieve the itens. Can u help me?
Code:
local config = {
storage = 15217,
items = {
[1] = {
{2188, 1},
},
[2] = {
{2185, 1},
},
[3] = {
{7367, 10},
},
[4] = {
{7432, 1},
{8209, 1},
{8601, 1},
},
default = {
{2160, 2},
}
}
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if(item.uid == 37900) then
if(player:getStorageValue(config.storage) == -1) then
local bag = player:addItem(1987, 1)
if (bag) then
if player:getStorageValue(config.storage) < 1 then
for _, item in pairs(config.items.default) do
player:addItem(item[1], item[2])
end
end
end
local vocation = config.items[player:getVocation():getId()]
if vocation then
for _, item in pairs(vocation) do
bag:addItem(item[1], item[2])
end
end
player:addMount(config.mount_id)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You found a bag and donkey mount.")
player:getPosition():sendMagicEffect(32)
player:setStorageValue(config.storage, 1)
else
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The chest is empty.")
end
end
return true
end