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

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


Forum Jump:


Users browsing this thread: 2 Guest(s)