Connection Logs - 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: Connection Logs (
/showthread.php?tid=472519)
Connection Logs -
MaxPierce - 29.10.2013
Hey all.
I just wanted to know if it was possible to make a log that would show a list of a user's connected time to the server..
For example: One day, Max would login at 02:01 and log out at 02:02 but I want to see the xxx hours xxx minutes xxx seconds.
Yes, I tried it but I failed so now I'm asking for help!
Re: Connection Logs -
arakuta - 29.10.2013
You can use the default log for this, using printf and gettime when player diconnects.
pawn Код:
new LoginTime[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
LoginTime[playerid] == gettime();
return 1;
}
public OnPlayerDisconnect(playerid,reason)
{
new n[24];
GetPlayerName(playerid,n,24);
printf("Player %s had been online for %s",ConvertSeconds(gettime() - LoginTime[playerid]));
}
stock ConvertSeconds(seconds)
{
new hours, mins, secs, string[50];
hours = floatround(number / 3600);
mins = floatround((number / 60) - (hours * 60));
secs = floatround(number - ((hours * 3600) + (mins * 60)));
new days = 0;
if(hours >= 24)
{
days = floatround((hours/24), floatround_floor);
hours = hours % 24;
}
if(days > 0)
format(string, 50, "%dd, %dh %dm and %ds", days, hours, mins, secs);
else if(hours > 0)
format(string, 50, "%dh %dm and %ds", hours, mins, secs);
else
format(string, 50, "%dm and %ds", mins, secs);
return string;
}
Re: Connection Logs -
MaxPierce - 30.10.2013
Thanks! Sadly, I received numerous errors not related to this....but the errors go away when I remove the script from my GM.
Re: Connection Logs -
RayDcosta - 31.10.2013
better thing to do, just check ur server.log in the server directory.
it shows u the time in hh:mm
s format.
the only down side to it is that it doesnt show u the day/date.
for that u need to make a custom log.
like under OnPlayerConnect you can make a formatted string to log...
[%d/%d/%d (date) %d:%d:%d(custom timestamp) %s (playername) %d (player ip) has logged in"
and then under OnPlayer Disconnect
(variables in a similar manner) ...........has logged off.
hope it helped.
if you didnt understand, temme which part, and ill explain till u dont. cheers