Saving online time with a MySQL event
#1

I was just about to create a timer to update all online players' online time in a MySQL table every 5 minutes, but then I thought... would a MySQL event be better? Something like:

Code:
CREATE EVENT update_time ON SCHEDULE EVERY 1 SECOND DO
  UPDATE users SET on‌linetime = onlinetime + 1 WHERE on‌line = 1;
Or to decrease the amount of load, even:
Code:
CREATE EVENT update_time ON SCHEDULE EVERY 60 SECOND DO
  UPDATE users SET on‌linetime = onlinetime + 60 WHERE on‌line = 1;
Would it be slow/inefficient for MySQL to search through potentially thousands of rows for online players?

Or perhaps I could have a separate table that adds a row for users when they come online in-game, and deletes the row when they disconnect, and have the event update if their ID exists in that table? What do you think?

Edit: obviously, when a player disconnects their online time will be saved from the gamemode.
Reply
#2

Do it within pawn, and save it when player leaves the server.
Reply
#3

Do you need the amount of time through MySQL, out of the game server?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)