SA-MP Forums Archive
How to save playtime of a player - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to save playtime of a player (/showthread.php?tid=618905)



How to save playtime of a player - Ronaldo1234 - 11.10.2016

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?


Re: How to save playtime of a player - iLearner - 11.10.2016

GetPlayerConnectedTime()

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


Re: How to save playtime of a player - Ronaldo1234 - 11.10.2016

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

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


Re: How to save playtime of a player - AndySedeyn - 11.10.2016

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


Re: How to save playtime of a player - Rdx - 11.10.2016

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);



Re: How to save playtime of a player - Vince - 11.10.2016

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.


Re: How to save playtime of a player - iLearner - 11.10.2016

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.