SetTimerEx help needed
#1

hello,

im trying to make a paycheck. Its a bit diffrent then others, but the timer needs to repeat...
I used this:

gamemodeinit

Код:
paychecktimer4 = SetTimerEx("paychecktimer1", 900000, true, "i");
Then the forward paychecktimer4

Код:
public paychecktimer1(playerid)
{
paycheck[playerid] = 0;
paychecktimer3 = SetTimer("paychecktimer2", 300000, false);
SendClientMessageToAll(COLOR_RED, "[PAYCHECK] "green"You are now avaible to pick up your "white"Paycheck "green"at the LS city hall (Ask players) For playing 15 minutes Ultimate Stunts!");
SendClientMessageToAll(COLOR_RED, "[PAYCHECK] "green"Hurry! Because you have only "white"5 minutes to get it. "green"Type /paycheck at the place where it says that you need to do it.");
return 1;
}
I have all the new blabla; stuff etc, no errors. But in what i need to change the I from the settimerex? So it just go to that forward...?
thnx
Reply
#2

How can i get that paychecktimer4 goes to the public?
I tried with settimer but diddnt work. Its need to repeat to!!!
Reply
#3

You need to pass the playerid to the function, but when OnGameModeInit executes there are no players connected (and it has no playerid parameter).
You need to start this timer somewhere under OnPlayerConnect or OnPlayerSpawn, while making sure that the timer doesn't get set multiple times and that it gets killed appropriately when a player disconnects.

pawn Код:
paychecktimer4 = SetTimerEx("paychecktimer1", 900000, true, "i", playerid);
Reply
#4

Undfer OnPlayerConnect
pawn Код:
SetTimerEx("PayCheckTimer", 900000, true, "i", playerid);
pawn Код:
public PayCheckTimer(playerid)
{
SendClientMessageToAll(COLOR_RED, "[PAYCHECK] "green"You are now avaible to pick up your "white"Paycheck "green"at the LS city hall (Ask players) For playing 15 minutes Ultimate Stunts!");
SendClientMessageToAll(COLOR_RED, "[PAYCHECK] "green"Hurry! Because you have only "white"5 minutes to get it. "green"Type /paycheck at the place where it says that you need to do it.");
return 1;
}
Now, the PayCheckTimer will repeat every 900.000 ms. You don't have to use a timer in a timer, in a timer.

I hope this is what you're looking for.


Or, you could do the timer under "OnGameModeInit" but you need a loop inside the timer function. For example:
pawn Код:
public OnGameModeInit()
{
    SetTimer("PayCheckTimer", 900000, true);
}
And now, in the timer:
pawn Код:
public PayCheckTimer()
{
        for(new i=0; i<MAX_PLAYERS; i++)
        {
                if(IsPlayerConnected(i))
                {
                      //Here you do whatever you want.
                }
         }
}
Reply
#5

thnx but i did that timer in the timer because i want that you have only 5 minutes to recieve a paycheck
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)