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: Time (
/showthread.php?tid=297779)
Time -
omer5198 - 17.11.2011
How can i check how much time someone was in server? i mean... i want to make a "Money Giving" every hour and that the system will calculate it with the time he was connected out of the hour... how can i do it without getting my server very laggy?
Re: Time -
Miguel - 17.11.2011
Global variable:
pawn Код:
new initRef[MAX_PLAYERS] = {0, ...};
When they join:
pawn Код:
initRef[playerid] = GetTickCount();
Whenever you want the server to give them the money.
pawn Код:
new online = (GetTickCount() - initRef[playerid]) / 1000;
"online" will be the time they were in the server in seconds.
Re: Time -
MP2 - 17.11.2011
A better way would be to set a variable to 60, and every minute reduce it by 1, when it reaches 0 give them money and set it back to 60. Make sure you save the value to their account also.