function onAdvance(cid, skill, oldLevel, newLevel)
local cfg = {}
cfg.prizes = { {2160,5} }
cfg.level = 50
cfg.storage = 15512
if(skill == SKILL__LEVEL) then
if(newLevel == cfg.level) then
if(getPlayerStorageValue(cid, cfg.storage) == -1) then
for i = 1, #cfg.prizes do
doPlayerAddItem(cid, cfg.prizes[i][1], cfg.prizes[i][2])
end
setPlayerStorageValue(cid, cfg.storage, 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "CONGRATULATIONS! You've reached level " .. cfg.level .. ".")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You have already received your prize for level " .. cfg.level .. ".")
end
end
end
return true
end
watJDB~
Your scripts are way to long, it could be much shorter.
local t = {
-- [storage], level, itemid, count
[15512] = {50, 2160, 5}
}
function onAdvance(cid, skill, oldLevel, newLevel)
if skill == SKILL__LEVEL then
for storage, v in pairs(t) do
if newLevel >= v[1] and getPlayerStorageValue(cid, storage) < 1 then
doPlayerAddItem(cid, v[2], v[3])
setPlayerStorageValue(cid, storage, 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "CONGRATULATIONS! You've reached level " .. v[1] .. ".")
break
end
end
end
return true
end
Yes, it stops/ends the current loop.break is a command to kick out of the for loop i think
local sirion ={
level = 50, -- level que irل ganhar
storage = 9557, -- storage
msg = "we have added 5cc for reach level 50", -- what message to say when take money
qnt = 5, -- how many crystal coin to reward
msgtp = MESSAGE_EVENT_ADVANCE,
itemid = 2160 -- id of crystal coin
}
function onAdvance(cid, oldLevel, newLevel)
if getPlayerStorageValue(cid, sirion.storage) < 1 and getPlayerLevel(cid) >= sirion.level then
doPlayerAddItem(cid, sirion.itemid, sirion.qnt)
setPlayerStorageValue(cid, sirion.storage, 1)
doPlayerSendTextMessage(cid, config.sirion, sirion.msg)
end
return TRUE
end