Online time - 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: Online time (
/showthread.php?tid=650863)
Online time -
ivndosos - 08.03.2018
So I have this little snippet out of my stats command, basically my issue is that everyone have the same online time,
Also, let's say there are 2 players in-game.
I played for 1 hour, he played for 1 hour too,
I reconnect so I'm gonna have it all resetted(as it's suppose to be), but the first player's online time will be resetted too
Код:
format(iString,sizeof(iString),"{ffff99}Online Time: %d hours | %d minutes | %d seconds", hours, minutes, seconds);
SendClientMessage(playerid, -1, iString);
}
return 1;
}
stock GetPlayerConnectedTime(playerid, &hours, &minutes, &seconds)
{
new onlinetime = NetStats_GetConnectedTime(playerid);
seconds = (onlinetime / 1000) % 60;
minutes = (onlinetime / (1000 * 60)) % 60;
hours = (onlinetime / (1000 * 60 * 60));
return 1;
}
Re: Online time -
jasperschellekens - 08.03.2018
Can u show NetStats_GetConnectedTime(playerid)?
How are you saving and loading the players connected time?
Re: Online time -
ivndosos - 08.03.2018
This is the whole code, I'm not trying to save the online time, It's just the time since he connected, It works but as I've stated above the only problem is it resets for everyone if someone disconnects and reconnects.
Re: Online time -
jasperschellekens - 08.03.2018
Quote:
Originally Posted by ivndosos
This is the whole code, I'm not trying to save the online time, It's just the time since he connected, It works but as I've stated above the only problem is it resets for everyone if someone disconnects and reconnects.
|
These are all global:
PHP код:
seconds = (onlinetime / 1000) % 60;
minutes = (onlinetime / (1000 * 60)) % 60;
hours = (onlinetime / (1000 * 60 * 60));
Store the online time in a player ar e.g hours[playerid]
Re: Online time -
Sew_Sumi - 08.03.2018
OP post more of the code that you posted the last 3 lines of... More above that is where something will reside.
Above this...
PHP код:
format(iString,sizeof(iString),"{ffff99}Online Time: %d hours | %d minutes | %d seconds", hours, minutes, seconds);
SendClientMessage(playerid, -1, iString);
}
return 1;
}
You haven't posted all the code, as what's above that code SHOULD be the function to retrieve their time online.
Also where did you define hours/minutes/seconds?