Time on Server - 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: Time on Server (
/showthread.php?tid=575402)
Time on Server -
kalanerik99 - 26.05.2015
Hello All
I have a code:
Код:
public OnPlayerConnect(playerid)
{
PlayerInfo[playerid][PTScore] = GetTickCount();
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
PlayerInfo[playerid][PTScore] = GetTickCount() - PlayerInfo[playerid][PTScore];
}
How to make that it will update PTScore when playing the server
PTSCORE is playtime score (IN HOURS) (I need it in hours)
NO TIMERS !!!!!
Re: Time on Server -
Vince - 26.05.2015
Use gettime instead. Returns the value in seconds and is more reliable.
pawn Код:
stock sec_to_time(timestamp, &hours, &minutes, &seconds)
{
hours = timestamp / 3600; // int divided by int is int
timestamp -= (hours * 3600);
minutes = timestamp / 60;
timestamp -= (minutes * 60);
seconds = timestamp;
}
Re: Time on Server -
kalanerik99 - 26.05.2015
#Vince can you show me a look of it !
(gettime....)
Re: Time on Server -
Beckett - 26.05.2015
Код:
public OnPlayerConnect(playerid)
{
PlayerInfo[playerid][PTScore] = 0;
PlayerInfo[playerid][TimePlayedLastLogin] = gettime();
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new current_time = gettime();
current_time -= PlayerInfo[playerid][TimePlayedLastLogin];
PlayerInfo[playerid][PTScore] += current_time/3600; // 3600 seconds = 60 minutes = 1 hour
}
Untested!
Re: Time on Server -
kalanerik99 - 26.05.2015
I will be saving PTScore And I want that it will refresh when player is playing on the server
Re: Time on Server -
Beckett - 26.05.2015
Not sure what you meant but this what I got.
pawn Код:
PlayerInfo[playerid][PTScore] = current_time/3600; // Sets the hours not increases the variable.
Re: Time on Server -
kalanerik99 - 26.05.2015
OK Thanks And I will put it where I have to refresh stats ?
Re: Time on Server -
Beckett - 26.05.2015
I really don't understand you, you want to save the stats or what?
Elaborate please.
Re: Time on Server -
kalanerik99 - 26.05.2015
Yea and that it will refresh them
Re: Time on Server -
Beckett - 26.05.2015
Use the magical button which leads you to the depths of the shadow realm, the "Search" button and find some saving systems.