Timer When Player is Offline
#1

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?
Reply
#2

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

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

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?
Reply
#5

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.");
}
Reply
#6

That will never work.
Reply
#7

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.
Reply
#8

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.

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)