local config, storage = {
[{1, 5}] = {
[20] = {
{
{2160, 1}, {2159, 1}
}
},
[30] = {
{
{2160, 3}, {2159, 3}
}
},
[40] = {
{
{2160, 5}, {2159, 5}
}
}
},
[{2, 6}] = {
[20] = {
{
{2160, 1}, {2159, 1}
}
},
[30] = {
{
{2160, 3}, {2159, 3}
}
},
[40] = {
{
{2160, 5}, {2159, 5}
}
}
},
[{3, 7}] = {
[20] = {
{
{2160, 1}, {2159, 1}
}
},
[30] = {
{
{2160, 3}, {2159, 3}
}
},
[40] = {
{
{2160, 5}, {2159, 5}
}
}
},
[{4, 8}] = {
[20] = {
{
{2160, 1}, {2159, 1}
}
},
[30] = {
{
{2160, 3}, {2159, 3}
}
},
[40] = {
{
{2160, 5}, {2159, 5}
}
}
}
}, 123
function onAdvance(cid, skill, oldLevel, newLevel)
local player = Player(cid)
if skill ~= 8 then
return true
end
for vocation, k in pairs(config) do
if isInArray(vocation, player:getVocation():getId()) then
for level, v in pairs(k) do
if newLevel >= level and player:getStorageValue(storage + level) ~= 1 then
local text = ""
for i = 1, #v[1] do
local itemType = ItemType(v[1][i][1])
text = text .. (i ~= 1 and (i == #v[1] and " and " or ", ") or "") .. (v[1][i][2] > 1 and v[1][i][2] or itemType:getArticle()) .. " " .. (v[1][i][2] > 1 and itemType:getPluralName() or itemType:getName())
player:addItem(v[1][i][1], v[1][i][2])
end
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("Congratulations, you reached level %d and received %s.", level, text))
player:setStorageValue(storage + level, 1)
end
end
end
end
return true
end