Server Time Tracking Issue
#5

Quote:
Originally Posted by [KHK]Khalid
Посмотреть сообщение
In my opinion, this is a bad way of doing it, with timers, I think it'll decrease server performance a lot as long as new players keep joining. I have a better way of doing it perhaps, check it out because I dunno if it works, however it should do:

pawn Код:
enum PLAYER_SPENT_TIME_STRUCT
{
    connectedAtHr, // When did this player connect to our server (hour)?
    connectedAtMin, // ~ ~ ~ minute ~ ~ ~
    connectedAtSec  // ~ ~ ~ second ~ ~ ~
}

new PlayerConnectedTime[MAX_PLAYERS][PLAYER_SPENT_TIME_STRUCT];

public OnPlayerConnect()
{
    // Update player new time
    // gettime gets the current time in hours, minutes and seconds
    // So this is when they connected
    gettime(PlayerConnectedTime[playerid][connectedAtHr], PlayerConnectedTime[playerid][connectedAtMin], PlayerConnectedTime[playerid][connectedAtSec]);
    return 1;
}

public OnPlayerDisconnect()
{
    // Now they're leaving the server
    // Let's see the difference between time now and time when they connected
    // Yes, we can do that as we've saved it in the PlayerConnectedTime variables
    new curHr, curMin, curSec;
    gettime(curHr, curMin, curSec);
    new newHrs, newMins, newSecs;
    newHrs = curHr - PlayerConnectedTime[playerid][connectedAtHr];
    newSecs = curSec - PlayerConnectedTime[playerid][connectedAtSec];
    newMins = curMin - PlayerConnectedTime[playerid][connectedAtMin];
    // Now newHrs, newMins, newSecs is the newly spent time
    // Do whatever you want with them!
    return 1;
}
Quote:
Originally Posted by Yashas
Посмотреть сообщение
NetStats_GetConnectedTime

You don't need a timer dedicated to keep track of player's playing time.You can save some CPU by avoiding it
So once I actually get that time, how should I store it for when they go offline, just store it into the mysql table and when they reconnect retrieve that time and continue from that?
Reply


Messages In This Thread
Server Time Tracking Issue - by BR3TT - 14.06.2015, 00:23
Re: Server Time Tracking Issue - by J0sh... - 14.06.2015, 00:31
Re: Server Time Tracking Issue - by [KHK]Khalid - 14.06.2015, 02:45
Re: Server Time Tracking Issue - by Yashas - 14.06.2015, 04:18
Re: Server Time Tracking Issue - by BR3TT - 14.06.2015, 07:15
Re: Server Time Tracking Issue - by [KHK]Khalid - 14.06.2015, 14:00
Re: Server Time Tracking Issue - by Yashas - 14.06.2015, 15:51

Forum Jump:


Users browsing this thread: 1 Guest(s)