How to save playtime of a player
#1

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?
Reply
#2

GetPlayerConnectedTime()

There's a samp func that does it for you.
Reply
#3

Quote:
Originally Posted by iLearner
Посмотреть сообщение
GetPlayerConnectedTime()

There's a samp func that does it for you.
it can save the player connected time?
Reply
#4

Quote:
Originally Posted by iLearner
Посмотреть сообщение
GetPlayerConnectedTime()

There's a samp func that does it for you.
It's actually part of Gammix's include:
https://sampforum.blast.hk/showthread.php?tid=573961
Reply
#5

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);
Reply
#6

A bit obsolete because there is a native that does the same thing: https://sampwiki.blast.hk/wiki/NetStats_GetConnectedTime
When the player disconnects or requests the connected time, add this value to th existing value in their account.
Reply
#7

Quote:
Originally Posted by Vince
Посмотреть сообщение
A bit obsolete because there is a native that does the same thing: https://sampwiki.blast.hk/wiki/NetStats_GetConnectedTime
When the player disconnects or requests the connected time, add this value to th existing value in their account.
He explained what I said in a better way.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)