Explain me how to create "payday timer" ? - 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: Explain me how to create "payday timer" ? (
/showthread.php?tid=513259)
Explain me how to create "payday timer" ? -
Metharon - 15.05.2014
Hello , how can i create something like :
- At 15:00 to give players payday.
- If you wasn't online for minimum 20 minutes before payday , to don't get payday.
- An payday system without timer for 60 minutes , because like that i need to open the server only at 00 minute.. (I created an temporary system , but is broken , i need to open only at 00 minutes .. for example : 15:00 16:00 09:00 (fix hour) is a timer 60 minutes..
Re: Explain me how to create "payday timer" ? -
Koala818 - 15.05.2014
Well, first i recommend you to use a timerfix:
https://sampforum.blast.hk/showthread.php?tid=289675 or
https://sampforum.blast.hk/showthread.php?tid=375925 .
Then, you can create a timer that executes every minute, but starts exactly next 00 seconds like:
PHP код:
new h,mi,s;
gettime(h,mi,s);
SetTimer("aEachMinuteTimer", 60000-(s*1000), 0); //Execute aEachMinuteTimer at next 00 seconds
public aEachMinuteTimer()
{
EachMinuteTimer();//executes the timer because it's a new minute
SetTimer ( "EachMinuteTimer" , 60000 , 1 ) ; //Execute EachMinuteTimer at every minute from now on.
return 1;
}
Then, in EachMinuteTimer, you verify if it is hour 15 and minute 00 and if it is so, you give them payday:
PHP код:
public EachMinuteTimer()
{
new h,m,s;
gettime ( h,m,s );
if(h==15 && m==0){
foreach (Player , i) {//ForEach already verifies if Player is connected.
GivePlayerMoney(i,...);
}
}
For that "if only you spent 20 minutes on server" you can create a new array[MAX_PLAYERS] and OnPlayerConnect you make it 0, then in EachMinuteTimer you make array[i]++; then you put instead of "Payday ( i )", if(array[i]>=20){array[i]=0; Payday(i);}
Hope you understand.