y_timers when to use and wen not to use!
#1

  • Player Timers
How can i use this specific timer for players how much time a player has spent playing in a typical game-server.
Quote:

Example:
when player has logged-in into his/hers load's his time spent and proceeding with the timer, later on when the player left the server by quitting saving time and killing the player timer for each specific player

player function i'm using for now, testing purpose

Код:
ptask PlayingTime[1000](playerid)
{
	if(IsPlayerConnected(playerid))
	{
	    Player[playerid][Seconds]++;
		if(Player[playerid][Seconds] == 59)
		{
		    Player[playerid][Seconds] = 0;
		    Player[playerid][Minutes]++;
		}
		else if(Player[playerid][Minutes] == 59)
		{
		    Player[playerid][Minutes] = 0;
		    Player[playerid][Hours]++;
		}
	}
	return 1;
}
also should i change the operators?
Reply
#2

You shouldn't be using any timers for this task period! Definitely not to use!

gettime()
Reply
#3

why should i? please explain. gettime what for?
Reply
#4

A repeated 1 second timer to increase time vs
pawn Код:
new gPlayer_OnlineTime[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    gPlayer_OnlineTime[playerid] = gettime();
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new online_time = gettime() - gPlayer_OnlineTime[playerid];
    return 1;
}
What do you believe is better?

Now you only need to add the new online time to the previous and save it again as seconds. This can be converted, no need to save seconds, minutes, hours etc.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)