Code:
local config = {
[10] = {r = {2160, 1}},
[20] = {p = 20},
[30] = {p = 1, r = {2160, 3}},
[40] = {p = 1},
[50] = {p = 50, r = {2160, 5}},
[60] = {p = 60, r = {2160, 6}},
[70] = {p = 70, r = {2160, 7}},
[80] = {p = 80, r = {2160, 8}}
}
function onAdvance(cid, skill, oldLevel, newLevel)
if skill == SKILL__LEVEL then
for level, v in pairs(config) do
if newLevel >= level and getCreatureStorage(cid, 100 + level) < 0 then
if v.p then
db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. v.p .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end
if v.r then
doPlayerAddItem(cid, v.r[1], v.r[2] or 1)
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You got" .. (v.p and " " .. v.p .. " point" or "") .. "" .. (v.p ~= nil and v.p > 1 and "s" or "") .. " " .. (v.p == nil and v.r and "reward " or "") .. "" .. (v.p ~= nil and v.r and "and reward " or "") .. "for advanced from Level " .. oldLevel .. " to Level " .. newLevel .. ".")
doCreatureSetStorage(cid, 100 + level, 1)
end
end
end
doPlayerSave(cid, true)
return true
end
Last edited: