Callback problem
#19

Quote:
Originally Posted by SapMan
Посмотреть сообщение
That is, I must use three times "for (new i = 0, j = GetPlayerPoolSize (); i <= j; i ++)"?

Please, I need a quick help.
You can add a check to the second loop.

That way only one of those loops will ever be executed at once (so technically it's just one loop per execution).

Even if it were 3, those aren't very complex loops so I don't see how there would be any issues.

PHP код:
public DerbyCountdown() 

    if(
DI[STATUS] != DERBY_WAIT) return KillTimer(DI[COUNTDOWN_TIMER]); 
    if(
DI[PLAYERS] <= 0) return CloseDerby(); 
    if(
DI[PLAYERS] == 1
    { 
        
DI[COUNTDOWN_COUNTER] = DERBY_TIME_COUNTDOWN 1
        for(new 
playerid 0GetPlayerPoolSize(); playerid <= jplayerid++) 
        { 
            if(
IsPlayerConnected(playerid)) 
            { 
                if(
Player[playerid][Mode] == GAME_DERBY
                { 
                    
GameTextForPlayer(playerid"~g~Waiting for players"5003); 
                } 
            } 
        } 
        return 
1
    } 
    
DI[COUNTDOWN_COUNTER] --; 
    if(
DI[COUNTDOWN_COUNTER] > 0)
    { 
        for(new 
playerid 0GetPlayerPoolSize(); playerid <= jplayerid++)
        { 
            if(
IsPlayerConnected(playerid)) 
            { 
                if(
Player[playerid][Mode] == GAME_DERBY
                { 
                    new 
str[10]; format(str10"~r~%d_minutes_to_start"DI[COUNTDOWN_COUNTER]); 
                    
GameTextForPlayer(playeridstr10003);  
                } 
            } 
        } 
    }
    else
    { 
        
KillTimer(DI[COUNTDOWN_TIMER]); 
        if(
DI[PLAYERS] == 0) return CloseDerby(); 
        else if(
DI[PLAYERS] == 1
        { 
            for(new 
playerid 0GetPlayerPoolSize(); playerid <= jplayerid++) 
            { 
                if(
IsPlayerConnected(playerid)) 
                { 
                    if(
Player[playerid][Mode] == GAME_DERBY
                    { 
                        
GameTextForPlayer(playerid"~g~Waiting for players"5003); 
                    } 
                } 
            } 
            
DI[COUNTDOWN_COUNTER] = DERBY_TIME_COUNTDOWN 1
            
KillTimer(DI[COUNTDOWN_TIMER]); 
            
DI[COUNTDOWN_TIMER] = SetTimer("DerbyCountdown"900true); 
        } 
        else 
StartDerby(); 
    } 
    return 
1

The second loop doesn't need to be executed when the time reached 0, since you want to start the derby at that moment.
Reply


Messages In This Thread
Callback problem - by SapMan - 12.09.2018, 00:06
Re: Callback problem - by SapMan - 12.09.2018, 00:52
Re: Callback problem - by sammp - 12.09.2018, 02:42
Re: Callback problem - by SapMan - 12.09.2018, 02:54
Re: Callback problem - by iHollyZinhO - 12.09.2018, 03:19
Re: Callback problem - by NaS - 12.09.2018, 15:46
Re: Callback problem - by SapMan - 12.09.2018, 20:57
Re: Callback problem - by UFF - 12.09.2018, 21:05
Re: Callback problem - by SapMan - 12.09.2018, 21:20
Re: Callback problem - by Shinja - 12.09.2018, 23:53
Re: Callback problem - by SapMan - 13.09.2018, 01:13
Re: Callback problem - by Shinja - 13.09.2018, 11:10
Re: Callback problem - by SapMan - 13.09.2018, 16:36
Re: Callback problem - by KinderClans - 13.09.2018, 16:45
Re: Callback problem - by SapMan - 13.09.2018, 17:00
Re: Callback problem - by Dayrion - 13.09.2018, 19:06
Re: Callback problem - by KinderClans - 13.09.2018, 19:25
Re: Callback problem - by Undef1ned - 14.09.2018, 15:52
Re: Callback problem - by NaS - 14.09.2018, 16:08

Forum Jump:


Users browsing this thread: 4 Guest(s)