• 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] Donate points when you level up (use chest - not creaturescript)

Napes

Owner of napes.se
Joined
May 11, 2014
Messages
63
Reaction score
2
Location
Sweden
Title pretty much explains it all..
Using TFS 1.0

I want to have 3 chests where you get certain amount of points when you reach lvl x.
I don't want creaturescript so that they get it when they're hunting, they need to open chest in temple.

Thanks!
 
Code:
local config, storage = {
    {level = 30, points = 2},
    {level = 50, points = 3},
    {level = 100, points = 4}
}, 8000

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    for i = 1, #config do
        if player:getLevel() >= config[i].level and player:getStorageValue(storage) < i then
            db.query("UPDATE `znote_accounts` SET `points` = `points` + " .. config[i].points .. " WHERE `account_id` = " .. player:getAccountId())
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("Congratulations! You have been rewarded with %d donation points for reaching level %d!", config[i].points, config[i].level))
            player:setStorageValue(storage, i)
            break
        end
    end
    return true
end
 
Code:
local config, storage = {
    {level = 30, points = 2},
    {level = 50, points = 3},
    {level = 100, points = 4}
}, 8000

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    for i = 1, #config do
        if player:getLevel() >= config[i].level and player:getStorageValue(storage) < i then
            db.query("UPDATE `znote_accounts` SET `points` = `points` + " .. config[i].points .. " WHERE `account_id` = " .. player:getAccountId())
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("Congratulations! You have been rewarded with %d donation points for reaching level %d!", config[i].points, config[i].level))
            player:setStorageValue(storage, i)
            break
        end
    end
    return true
end
where can i put this? i mean what position of it? :D
 
Back
Top