Hello!
I've got a script that gives rewards for advancing to a certain level. It works just fine as long as the reward is just one item. I'd like it to be at least three items. This is the original script that I tried customizing:
My customization that doesn't work:
What have I done wrong?
I've got a script that gives rewards for advancing to a certain level. It works just fine as long as the reward is just one item. I'd like it to be at least three items. This is the original script that I tried customizing:
Code:
local tabela = {
[30] = {item_id = 2160, quantidade = 5, mensagem = "You have been awarded with 5 crystal coin for reaching level 30",1},
[50] = {item_id = 2160, quantidade = 6, mensagem = "You have been awarded with 6 crystal coin for reaching level 50!",2},
[75] = {item_id = 2160, quantidade = 8, mensagem = "You have been awarded with 8 crystal coin for reaching level 75!",3},
[100] = {item_id = 2160, quantidade = 20, mensagem = "You have been awarded with 20 crystal coin for reaching level 100!",4}
}
local storage = 15000
function onAdvance(cid, skill, oldlevel, newlevel)
local player = Player(cid)
if skill == 8 then
for level, _ in pairs(tabela) do
if player:getLevel() >= level and player:getStorageValue(storage) < level then
player:addItem(tabela[level].item_id, tabela[level].quantidade)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, tabela[level].mensagem)
player:setStorageValue(storage, level)
end
end
end
player:save()
return true
end
My customization that doesn't work:
Code:
local tabela = {
[20] = {item_id = 2160, quantidade = 3, mensagem = "You have been awarded with 3 crystal coin for reaching level 20.",1},
[35] = {{item_id = 7392, quantidade = 1, item_id = 7406, quantidade = 1, item_id = 7380, quantidade = 1}, mensagem = "You have been awarded with some supplies for level 35.",2},
[50] = {{item_id = 7383, quantidade = 1, item_id = 2391, quantidade = 1, item_id = 15454, quantidade = 1}, mensagem = "You have been awarded with some supplies for level 50.",3},
[75] = {{item_id = 7429, quantidade = 1, item_id = 7390, quantidade = 1, item_id = 7434, quantidade = 1, item_id = 2160, quantidade = 5}, mensagem = "You have been awarded with some supplies for level 75.",4}
}
local storage = 15000
function onAdvance(cid, skill, oldlevel, newlevel)
local player = Player(cid)
if skill == 8 then
for level, _ in pairs(tabela) do
if player:getLevel() >= level and player:getStorageValue(storage) < level then
player:addItem(tabela[level].item_id, tabela[level].quantidade)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, tabela[level].mensagem)
player:setStorageValue(storage, level)
end
end
end
player:save()
return true
end
What have I done wrong?