Players online time in server H/M/S - 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: Players online time in server H/M/S (
/showthread.php?tid=201271)
Players online time in server H/M/S -
maisto5 - 20.12.2010
Hello. How do I detect which player how much time was online on the server. Hours Minutes Seconds. Ladmin system but has a bug. Thanks in advance!
Re: Players online time in server H/M/S -
Tigerbeast11 - 31.08.2011
I would like to know this as well... How could you save the amout of time that the player has played your server?
Re: Players online time in server H/M/S -
Pinguinn - 31.08.2011
What are you using, y_ini, mysql?
Re: Players online time in server H/M/S -
MadeMan - 31.08.2011
Use a timer.
Re: Players online time in server H/M/S -
=WoR=Varth - 31.08.2011
https://sampwiki.blast.hk/wiki/Gettime
Re: Players online time in server H/M/S -
iPLEOMAX - 31.08.2011
Merge this into your script:
pawn Код:
#include <a_samp>
//#include <foreach>
new
CheckEachTimer,
PlayerSeconds[MAX_PLAYERS]
;
public OnFilterScriptInit()
{
CheckEachTimer = SetTimer("CheckEachPlayer", 1000, true);
return true;
}
public OnFilterScriptExit()
{
KillTimer(CheckEachTimer);
return true;
}
public OnPlayerConnect(playerid)
{
PlayerSeconds[playerid] = 0;
return true;
}
public OnPlayerDisconnect(playerid, reason)
{
new hh, mm, ss;
GetPlayerOnlineTime(playerid, hh, mm, ss);
printf("ID%i was online for %i hours %i minutes %i seconds.",playerid,hh,mm,ss);
return true;
}
forward CheckEachPlayer();
public CheckEachPlayer()
{
#if defined foreach
foreach(Player, i) { if(IsPlayerConnected(i)) PlayerSeconds[i]++; }
#else
for(new i=0; i<MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) PlayerSeconds[i]++; }
#endif
return true;
}
stock GetPlayerOnlineTime(playerid, &hours, &minutes, &seconds)
{
hours = (PlayerSeconds[playerid]/(60*60))%24;
minutes = (PlayerSeconds[playerid]/60)%60;
seconds = PlayerSeconds[playerid]%60;
}
Re: Players online time in server H/M/S -
Tigerbeast11 - 31.08.2011
But I want to save it in the .ini file using y_ini
eg.
Код:
Name=Tigerbeast11
Password=HasedPassword
Cash=200
Hours Online=2
Minutes Online=34
So in this .ini file, the player has been online for 2 hours and 34 minutes.
Re: Players online time in server H/M/S -
iPLEOMAX - 31.08.2011
Quote:
Originally Posted by Tigerbeast11
But I want to save it in the .ini file using y_ini
eg.
Код:
Name=Tigerbeast11
Password=HasedPassword
Cash=200
Hours Online=2
Minutes Online=34
So in this .ini file, the player has been online for 2 hours and 34 minutes.
|
Look up some Register/Login tutorial for Y_INI.
And then modify this:
pawn Код:
public OnPlayerLogin(playerid, password) //or connect.
{
//If success:
//Load the userfile...
PlayerSeconds[playerid] = PlayerInfo[playerid][pSeconds]; //According to your variable.
return true;
}
public OnPlayerDisconnect(playerid, reason)
{
PlayerInfo[playerid][pSeconds] = PlayerSeconds[playerid];
//Then save the userfile.
return true;
}
Re: Players online time in server H/M/S -
Tigerbeast11 - 01.09.2011
OK, thanks...