Hello guys!
I'm trying to get running this script, but I keep having an error which I don't know how to fix it because I can't find where is the bug.
First of all here is the error I'm getting:
And here is the script:
I already put the code on creaturescripts.xml so everything should be working just fine...
Hope someone can help me!
Thanks!
I'm trying to get running this script, but I keep having an error which I don't know how to fix it because I can't find where is the bug.
First of all here is the error I'm getting:
And here is the script:
Code:
local prizes = {
[60001] = {level = 20, reward = {2152, 50}},
[60002] = {level = 35, reward = {2160, 1}},
[60003] = {level = 50, reward = {2160, 2}},
[60004] = {level = 80, reward = {2160, 3}},
[60005] = {level = 120, reward = {2160, 4}},
[60006] = {level = 160, reward = {2160, 5}},
[60007] = {level = 200, reward = {2160, 10}},
[60008] = {level = 250, reward = {{7958, 50}},
}
function onAdvance(cid, skill, oldlevel, newlevel)
if(skill ~= SKILL__LEVEL)then return TRUE end
for i,t in ipairs(prizes) do
if not(getPlayerStorageValue(cid, i)) and t.level <= newlevel then
if type(t.reward[1] ~= "table") then
local add = doPlayerAddItem(cid, t.reward[1], t.reward[2])
if add then
doPlayerSendTextMessage(cid, 19, "You have received ".t.reward[2]." ".getItemNameById(t.reward[2])." due to reaching level ".t.level.".")
setPlayerStorageValue(cid, i, true)
end
else
local bp = doCreateItemEx(1988, 1)
for _,item in ipairs(t.reward) do
doAddContainerItem(bp, item[1], item[2])
end
local add = doPlayerAddItemEx(cid, bp)
if add then
doPlayerSendTextMessage(cid, 19, "You have received backpack with items due to reaching level ".t.level.".")
setPlayerStorageValue(cid, i, true)
end
end
end
end
return TRUE
end
I already put the code on creaturescripts.xml so everything should be working just fine...
Hope someone can help me!
Thanks!