• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[TFS 1.0][GlobalEvent]Get gold after advance.

Actually It's a creatureevent.

Here you are.

function onAdvance(cid, skill, oldlevel, newlevel)

if(getPlayerStorageValue(cid, 99963) ~= 1 and skill == SKILL_LEVEL and newlevel >= 45) then
doPlayerAddItem(cid, 2160, 5)
setPlayerStorageValue(cid, 99963, 1)
doPlayerSendTextMessage(cid, 22, "You have received 5 crystal coins because you reached level 45")
end

if(getPlayerStorageValue(cid, 99964) ~= 1 and skill == SKILL_LEVEL and newlevel >= 100) then
doPlayerAddItem(cid, 2160, 10)
setPlayerStorageValue(cid, 99964, 1)
doPlayerSendTextMessage(cid, 22, "You have received 5 crystal coins because you reached level 100")
end

if(getPlayerStorageValue(cid, 99965) ~= 1 and skill == SKILL_LEVEL and newlevel >= 150) then
doPlayerAddItem(cid, 2160, 15)
setPlayerStorageValue(cid, 99965, 1)
doPlayerSendTextMessage(cid, 22, "You have received 5 crystal coins because you reached level 150")
end

if(getPlayerStorageValue(cid, 99966) ~= 1 and skill == SKILL_LEVEL and newlevel >= 200) then
doPlayerAddItem(cid, 2160, 20)
doPlayerAddItem(cid, 13529, 1)
setPlayerStorageValue(cid, 99966, 1)
doPlayerSendTextMessage(cid, 22, "You have received 5 crystal coins because you reached level 200")
end

if(getPlayerStorageValue(cid, 99967) ~= 1 and skill == SKILL_LEVEL and newlevel >= 250) then
doPlayerAddItem(cid, 2160, 30)
doPlayerAddItem(cid, 13581, 1)
setPlayerStorageValue(cid, 99967, 1)
doPlayerSendTextMessage(cid, 22, "You have received 5 crystal coins because you reached level 250")
end

return TRUE
end
 
With loops and clear config:
Code:
local config = {
    storage = 99960 -- reserved storages from X to X + amount of things in rewards below (now it's 5)
}

local rewards = {
    [1] = {level = 45, gold = 50000, items = {}},
    [2] = {level = 100, gold = 100000, items = {}},
    [3] = {level = 150, gold = 150000, items = {}},
    [4] = {level = 200, gold = 200000, items = {13529}},
    [5] = {level = 250, gold = 300000, items = {13581}}
}

-- YOU DONT HAVE TO TOUCH ANYTHING BELOW THIS LINE
local function doPlayerAddGold(cid, amount)
    local gold = {
        c = {2160, math.floor(amount/10000)},
        p = {2152, math.floor((amount-(c * 10000))/100)},
        g = {2148, (amount-(c * 10000 + p * 100))}
    }
    for k = 1, #gold do
        doPlayerAddItem(cid, gold[k][1], gold[k][2])
    end
    return true
end

function onAdvance(cid, skill, oldlevel, newlevel)
    if skill == SKILL__LEVEL then
        for i = 1, #rewards do
            if newLevel >= rewards[i].level and getPlayerStorageValue(cid, config.storage + i) ~= 1 then
                doPlayerAddGold(cid, rewards[i].gold)
                local line = ""
                if #rewards[i].items ~= nil then
                    line = "and extra reward "
                    for j = 1, #rewards[i].items do
                        doPlayerAddItem(cid, rewards[i].items[j])
                    end
                end
                setPlayerStorageValue(cid, config.storage + i, 1)
                doPlayerSendTextMessage(cid, 22, "You have received " ..rewards[i].gold.. " coins " ..line.. "because you reached level " ..rewards[i].level)
            end
        end
    end
    return true
end
 
Someone asked me on PM for vocation rewards. Now you can configure which voc gets the reward. If you leave it empty - then all vocs will get the reward.

dosn't work
#edit, fixed code bug, it was just one letter lel

Code:
local config = {
   storage = 99960 -- reserved storages from X to X + amount of things in rewards below (now it's 5)
}

local rewards = {
    [1] = {vocs = {}, level = 45, gold = 50000, items = {}}, -- in vocs {} is empty, that means every vocation gets the reward.
    [2] = {vocs = {}, level = 100, gold = 100000, items = {}},
    [3] = {vocs = {}, level = 150, gold = 150000, items = {}},
    [4] = {vocs = {}, level = 200, gold = 200000, items = {13529}},
    [5] = {vocs = {}, level = 250, gold = 300000, items = {13581}},
    [6] = {vocs = {3, 7}, level = 30, gold = 0, items = {2195}} -- vocs 3 and 7 (paladin and royal paladin) gets bohs (id 2195) at level 30
}

-- YOU DONT HAVE TO TOUCH ANYTHING BELOW THIS LINE
local function doPlayerAddGold(cid, amount)
    local gold = {
        c = {2160, math.floor(amount/10000)},
        p = {2152, math.floor((amount-(c * 10000))/100)},
        g = {2148, (amount-(c * 10000 + p * 100))}
    }
    for k = 1, #gold do
        doPlayerAddItem(cid, gold[k][1], gold[k][2])
    end
    return true
end

function onAdvance(cid, skill, oldlevel, newlevel)
    if skill == SKILL__LEVEL then
        for i = 1, #rewards do
            if newLevel >= rewards[i].level then
                if getPlayerStorageValue(cid, config.storage + i) ~= nil then
                    return true
                else
                    if (rewards[i].vocs ~= nil and isInArray(rewards[i].vocs, getPlayerVocation(cid)) == true) or rewards[i].vocs == nil then
                        doPlayerAddGold(cid, rewards[i].gold)
                        local line = ""
                        if #rewards[i].items ~= nil then
                            line = "and extra reward "
                            for j = 1, #rewards[i].items do
                                doPlayerAddItem(cid, rewards[i].items[j])
                            end
                        end
                        setPlayerStorageValue(cid, config.storage + i, 1)
                        doPlayerSendTextMessage(cid, 22, "You have received " ..rewards[i].gold.. " coins " ..line.. "because you reached level " ..rewards[i].level)
                    end
                end
            end
        end
    end
    return true
end
 
Last edited:
I test it and with
if skill == SKILL__LEVEL then
dosn't work
i change it for
if skill == 8 then
then i get that error
PHP:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/others/onadvance.lua:onAdvance
data/creaturescripts/scripts/others/onadvance.lua:38: attempt to compare number
with nil
stack traceback:
        [C]: in function '__le'
        data/creaturescripts/scripts/others/onadvance.lua:38: in function <data/
creaturescripts/scripts/others/onadvance.lua:35>
line 38
if newLevel >= rewards.level and getPlayerStorageValue(cid, config.storage + i) ~= 1 then Free games online
 
Last edited:
Back
Top