• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

How: gesior stuff for counting player online time

1268995

Member
Joined
Sep 9, 2010
Messages
422
Reaction score
13
Hello. I really dont know if i am posting this on the right place. Sorry if i am not.

I make some search and i do not find anything about that.

I was thinking about giving a reward for the most online player on the week.

But to do this i must know how much time all players spent online.

i was thinking about some stuff on gesior that count and shows the time all players spent playing on ot in that week. In the end of week, i can give o the wineer his reward. Any ideas?

THANKS!
 
This is most Online and also Powergamers, it's a bit old but it's everything you need:

https://otland.net/threads/gesior-acc-maker-tfs-0-3-5-powergamers-and-online-time-stats.44762/

As you said, this code are old.

In this script:

Code:
function onThink(interval, lastExecution)
    if (tonumber(os.date("%d")) ~= getGlobalStorageValue(23456)) then
        setGlobalStorageValue(23456, (tonumber(os.date("%d"))))
        db.executeQuery("UPDATE `players` SET `onlinetime7`=players.onlinetime6, `onlinetime6`=players.onlinetime5, `onlinetime5`=players.onlinetime4, `onlinetime4`=players.onlinetime3, `onlinetime3`=players.onlinetime2, `onlinetime2`=players.onlinetime1, `onlinetime1`=players.onlinetimetoday, `onlinetimetoday`=0;")
        db.executeQuery("UPDATE `players` SET `exphist7`=players.exphist6, `exphist6`=players.exphist5, `exphist5`=players.exphist4, `exphist4`=players.exphist3, `exphist3`=players.exphist2, `exphist2`=players.exphist1, `exphist1`=players.experience-players.exphist_lastexp, `exphist_lastexp`=players.experience;")
    end
    db.executeQuery("UPDATE `players` SET `onlinetimetoday`=players.onlinetimetoday+60, `onlinetimeall`=players.onlinetimeall+60 WHERE `online` = 1;")
    return TRUE
end

I changed to:

Code:
function onThink(interval, lastExecution)
    if (tonumber(os.date("%d")) ~= getGlobalStorageValue(23456)) then
        setGlobalStorageValue(23456, (tonumber(os.date("%d"))))
        db.query("UPDATE `players` SET `onlinetime7`=players.onlinetime6, `onlinetime6`=players.onlinetime5, `onlinetime5`=players.onlinetime4, `onlinetime4`=players.onlinetime3, `onlinetime3`=players.onlinetime2, `onlinetime2`=players.onlinetime1, `onlinetime1`=players.onlinetimetoday, `onlinetimetoday`=0;")
        db.query("UPDATE `players` SET `exphist7`=players.exphist6, `exphist6`=players.exphist5, `exphist5`=players.exphist4, `exphist4`=players.exphist3, `exphist3`=players.exphist2, `exphist2`=players.exphist1, `exphist1`=players.experience-players.exphist_lastexp, `exphist_lastexp`=players.experience;")
    end
    db.query("UPDATE `players` SET `onlinetimetoday`=players.onlinetimetoday+60, `onlinetimeall`=players.onlinetimeall+60 WHERE `online` = 1;")
    return TRUE
end

So, where existed db.executeQuery i putted db.query

If i leave the code as db.executeQuery, no error appear on console, but script do not work (do not appear players on most online).
If i leave the code as db.query appear the error on console:

Code:
[10/07/2015 14:47:56] [Error - GlobalEvent Interface]
[10/07/2015 14:47:56] data/globalevents/scripts/history.lua:onThink
[10/07/2015 14:47:56] Description:
[10/07/2015 14:47:56] data/globalevents/scripts/history.lua:7: attempt to call field 'query' (a nil value)
[10/07/2015 14:47:56] stack traceback:
[10/07/2015 14:47:56]     data/globalevents/scripts/history.lua:7: in function <data/globalevents/scripts/history.lua:1>
[10/07/2015 14:47:56] [Error - GlobalEvents::think] Couldn't execute event: history

How can i solve it?
 
Back
Top