• 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!

GlobalEvent New Record all players recive premium points!

Printer

if Printer then print("LUA") end
Senator
Premium User
Joined
Dec 27, 2009
Messages
5,782
Solutions
31
Reaction score
2,286
Location
Sweden?
Hello, this has been requested by this user: http://otland.net/threads/premium-points-for-players-online-record.201470/ so i had nothing todo and made it ^^

Only tested in: 0.3

As the title says, you can configure, when it reach a new record, how much points it should add and on which record it should add. Also it will check if you have znote acc or gesior acc!

You can easily replace whole record.lua in globalevent, but if it doesnt exsist just add this then in globalevents.xml

Code:
<globalevent name="record" type="record" event="script" value="record.lua"/>

and create new file and name it record.lua and paste the code below:
Code:
local config = { --[record] {amount of points}
    znote = "no", --If you use gesior acc leave it no
    [50] = {points = 100},
    [100] = {points = 200}
}

function onRecord(current, old, cid)
    for _, pid in ipairs(getPlayersOnline()) do
        if (config[current]) then
            if (config.znote == "yes") then
                db.executeQuery("UPDATE `znote_accounts` SET `points` = `points` + "..config[current].points.." WHERE `account_id` ='"..getPlayerAccount(pid).."'")      
            else
                db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + "..config[current].points.." WHERE `name` ='"..getPlayerAccount(pid).."'")  
            end
        end
    end
    if (config[current]) then
        addEvent(doBroadcastMessage, 150, "The server has reached a new record with "..current.." players online, all players which is online has recived "..config[current].points.." points.", MESSAGE_EVENT_ADVANCE)
    else
        addEvent(doBroadcastMessage, 150, "New record: " .. current .. " players are logged in.", MESSAGE_STATUS_DEFAULT)
    end
    db.executeQuery("INSERT INTO `server_record` (`record`, `world_id`, `timestamp`) VALUES (" .. current .. ", " .. getConfigValue('worldId') .. ", " .. os.time() .. ");")
    return true
end

Enjoy!
 
Im glad that you like it :)
 
Why would you check if there is a record entry for the current amount of players in ever iteration?
Also, you can just set the query once at the start.
Otherwise cool idea.
 
@Printer - I guess most servers would love to have this updated to TFS 1.1+ :)

Kind Regards,
Eldin.
 
@Printer - I guess most servers would love to have this updated to TFS 1.1+ :)

Kind Regards,
Eldin.
Code:
local config = { --[record] {amount of points}
    znote = "no", --If you use gesior acc leave it no
    [50] = {points = 100},
    [100] = {points = 200}
}

function onRecord(current, old)
    for _, player in ipairs(Game.getPlayers()) do
        if (config[current]) then
            if (config.znote == "yes") then
                db.query("UPDATE `znote_accounts` SET `points` = `points` + "..config[current].points.." WHERE `account_id` ='"..player:getAccountId().."'")    
            else
                db.query("UPDATE `accounts` SET `premium_points` = `premium_points` + "..config[current].points.." WHERE `name` ='"..player:getAccountId().."'")
            end
        end
    end
    if (config[current]) then
        addEvent(Game.broadcastMessage, 150, "The server has reached a new record with "..current.." players online, all players which is online has recived "..config[current].points.." points.", MESSAGE_EVENT_ADVANCE)
    else
        addEvent(Game.broadcastMessage, 150, "New record: " .. current .. " players are logged in.", MESSAGE_STATUS_DEFAULT)
    end
    db.query("INSERT INTO `server_record` (`record`, `world_id`, `timestamp`) VALUES (" .. current .. ", " .. getConfigValue('worldId') .. ", " .. os.time() .. ");")
    return true
end
 
@Codex NG
You're everywhere aren't you? :eek:
Im gonna have an extra look under my bed tonight.

I posted a small request in your scripting service too,
thank you for this! :)

Kind Regards,
Eldin.
 
Back
Top