Timer isn't working
#1

This are the codes

the problem is that the timer don't start :/

PHP код:
new ending
PHP код:
public OnGameModeInit()
{
    
    for (new 
id 0id MAX_PLAYERS;id++)
    {
        if(
IsPlayerConnected(id))
        {
         
SetTimerEx("Unfreeze"120000false"i"id);
        }
    }

PHP код:
forward Unfreeze(id);
public 
Unfreeze(id)
{
    
SendClientMessage(idCOLOR_PEACH"Test message");
     if(
spawn[id] == 1)
     {
        
TogglePlayerControllable(id1);
        
SendClientMessage(idCOLOR_PEACH"The race has been started! Go!");
    }
    
ending SetTimer("Next"180000false);
    return 
1;
}
forward Next();
public 
Next()
{
    
SendRconCommand("changemode Proj");
    return 
1;

i think every thing is fine, any help?
Reply
#2

You've put the timer at OnGameModeInit() which is being called exactly when the server loads up, which means there are no players online yet. You gotta put it in the start of the race. (as much as I see, you are building a race)
Reply
#3

Quote:
Originally Posted by ranme15
Посмотреть сообщение
You've put the timer at OnGameModeInit() which is being called exactly when the server loads up, which means there are no players online yet. You gotta put it in the start of the race. (as much as I see, you are building a race)
i was using this code:

PHP код:
SetTimer("Unfreeze"120000false); 
and the same thing, the timer didn't work. also the race will start when the timer end


Edit: the function "Unfreeze" will be called after 2 mns, and when i join the server, nothing happen
so the problem is the timer don't start at the 1st time
Reply
#4

You are doing it in wrong way, first you are starting timers under OnGameModeInit for every connected player (if(IsPlayerConnected(id))), at that point noone is connected.
SetTimer("Unfreeze", 120000, false);
False means don't reapeat action, do it just one time.
Reply
#5

Quote:
Originally Posted by Dragony92
Посмотреть сообщение
You are doing it in wrong way, first you are starting timers under OnGameModeInit for every connected player (if(IsPlayerConnected(id))), at that point noone is connected.
SetTimer("Unfreeze", 120000, false);
False means don't reapeat action, do it just one time.
i already said

Quote:
Originally Posted by mongi
Посмотреть сообщение
i was using this code:

PHP код:
SetTimer("Unfreeze"120000false); 
and the same thing, the timer didn't work. also the race will start when the timer end


Edit: the function "Unfreeze" will be called after 2 mns, and when i join the server, nothing happen
so the problem is the timer don't start at the 1st time
Reply
#6

You are not listening to what they said!
You are making a loop through the online players OnGameModeInit(), And this callback get called ONLY when you start the server!
You have to remove the loop and make the timer repeating and make the loop inside the timer.
Reply
#7

PHP код:
new ending
PHP код:
public OnGameModeInit()
{
    
SetTimer("Unfreeze"120000false); //After 2mns, "Unfreeze" will be called to unfreeze the online players
    
return 1;

PHP код:
forward Unfreeze();
public 
Unfreeze()
{
    for(new 
id=0;id<MAX_PLAYERS;id++)
    {
        
SendClientMessage(idCOLOR_PEACH"Test message");
         if(
spawn[id] == 1)
         {
            
TogglePlayerControllable(id1);
            
SendClientMessage(idCOLOR_PEACH"The race has been started! Go!");
        }
    }
    
ending SetTimer("Next"180000false);
    return 
1;
}
forward Next();
public 
Next()
{
    
SendRconCommand("changemode Proj");
    return 
1;

Reply
#8

I don't know ahat are you trying to do with this code, But it won't work for the players who join after 2 minutes of the server start.
Reply
#9

Quote:
Originally Posted by oMa37
Посмотреть сообщение
I don't know ahat are you trying to do with this code, But it won't work for the players who join after 2 minutes of the server start.
i already know this, and after 2 mns players won't be able to spawn b/c the race already started (i didn't finish the "unfreeze" function yet)

and the players who join before the 2mns, will be in cars and forzen, this function will unfreeze them.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)