Explain me how to create "payday timer" ?
#2

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 ) ; //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,);
    
    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.
Reply


Messages In This Thread
Explain me how to create "payday timer" ? - by Metharon - 15.05.2014, 13:03
Re: Explain me how to create "payday timer" ? - by Koala818 - 15.05.2014, 17:22

Forum Jump:


Users browsing this thread: 1 Guest(s)