SA-MP Forums Archive
Timer When Player is Offline - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Timer When Player is Offline (/showthread.php?tid=153051)



Timer When Player is Offline - NiGhTW0LF - 06.06.2010

Is there a way to make something like a timer (to work even if user is not online) to count let's say 3 days of player inactivity?


Re: Timer When Player is Offline - Conroy - 06.06.2010

Timers will still work even if the player is not connected.


Re: Timer When Player is Offline - NiGhTW0LF - 06.06.2010

Quote:
Originally Posted by Conroy
Timers will still work even if the player is not connected.
Thanks , I didn't know that.


Re: Timer When Player is Offline - Killa_ - 06.06.2010

Why dont you store the current date when they disconnect, then get the current date when they connect and work out the difference between the two?


Re: Timer When Player is Offline - coole210 - 07.06.2010

Quote:
Originally Posted by Killa_
Why dont you store the current date when they disconnect, then get the current date when they connect and work out the difference between the two?
I can script that for you..

Top of script:

Код:
new LastLogin[MAX_PLAYERS];
OnPlayerDisconnect:

Код:
LastLogin[playerid] = gettime();
Save it..

load it when they login..

Login:

Код:
if((gettime()-LastLogin[playerid]) < 259200)
{
}
else
{
SendClientMessage(playerid,COLOR,"You have been inactive for over 3 days.");
}



Re: Timer When Player is Offline - Killa_ - 07.06.2010

That will never work.


Re: Timer When Player is Offline - Calgon - 07.06.2010

Quote:
Originally Posted by Coole[AG
]
Quote:
Originally Posted by Killa_
Why dont you store the current date when they disconnect, then get the current date when they connect and work out the difference between the two?
I can script that for you..

Top of script:

Код:
new LastLogin[MAX_PLAYERS];
OnPlayerDisconnect:

Код:
LastLogin[playerid] = gettime();
Save it..

load it when they login..

Login:

Код:
if((gettime()-LastLogin[playerid]) < 259200)
{
}
else
{
SendClientMessage(playerid,COLOR,"You have been inactive for over 3 days.");
}
Along the right lines, but you're still far off.

https://sampwiki.blast.hk/wiki/Gettime - THIS WILL ONLY DISPLAY THE TIME, NOT THE DATE, AND YOU HAVE ENTERED THE PARAMETERS INCORRECTLY.

https://sampwiki.blast.hk/wiki/Getdate - You'll want to use this in conjunction with gettime with the correct parameters, using a few variables and saving them.


Re: Timer When Player is Offline - Kyosaur - 07.06.2010

Quote:
Originally Posted by Calgon
Quote:
Originally Posted by Coole[AG
]
Quote:
Originally Posted by Killa_
Why dont you store the current date when they disconnect, then get the current date when they connect and work out the difference between the two?
I can script that for you..

Top of script:

Код:
new LastLogin[MAX_PLAYERS];
OnPlayerDisconnect:

Код:
LastLogin[playerid] = gettime();
Save it..

load it when they login..

Login:

Код:
if((gettime()-LastLogin[playerid]) < 259200)
{
}
else
{
SendClientMessage(playerid,COLOR,"You have been inactive for over 3 days.");
}
Along the right lines, but you're still far off.

https://sampwiki.blast.hk/wiki/Gettime - THIS WILL ONLY DISPLAY THE TIME, NOT THE DATE, AND YOU HAVE ENTERED THE PARAMETERS INCORRECTLY.

https://sampwiki.blast.hk/wiki/Getdate - You'll want to use this in conjunction with gettime with the correct parameters, using a few variables and saving them.
His parameters were not wrong. Those are optional parameters, if you dont enter anything, the function will return how many seconds it has been since january 1 1970; which can be converted into days,months,years etc. So he's not to far off.