Posts: 41
Threads: 6
Joined: Aug 2016
Reputation:
0
hello everyone i have a playtime system it shows how many hours seconds and minutes player have played in the server but the problem is this is not working properply after hosting my server it counts every second perfect when i am turning on server from my pc but after hosted now it counting every minute in a sec that's cause of host poor performance and server lag and i am using it with a SetTimerEx on every seconds that timer counts the player play time so i think this is because of SetTimerEx so there's don't have any other solution which can count the player every Second without using SetTimerEx?
GetPlayerConnectedTime()
There's a samp func that does it for you.
Posts: 170
Threads: 10
Joined: Sep 2011
OnPlayerConnect:
Код:
pInfo[playerid][player_login_time] = gettime();
+ function:
Код:
stock GetPlayerOnlineTime(playerid)
{
new time = gettime() - pInfo[playerid][player_login_time];
return time;
}
Converting to minutes and hours:
Код:
new time = GetPlayerOnlineTime(playerid), hour = floatround(time/3600, floatround_floor);
time -= hour * 3600;
new minute = floatround(time/60, floatround_floor);
Usage:
Код:
new str[64];
format(str, sizeof(str), "You are playing for %d hours and %d minutes.", hour, minute);
SendClientMessage(playerid, -1, str);