Infinite Loops ? ( or Fallout problem ? )
#1

Hi guys. I'm here with another problem from my server.
I think i've made a mistake, and i created a infinite loop somewhere in my GM.
Well i was on my '/fallout' minigame, and when it was ended, and the winner was a player
the server freezed instantly.. i think is from Fallout because there server freezed.
But maybe i have more infinite loops in GM, idk. Can u tell me how to find it, and to explain me
what's is an infinite loop, what functions are creating him, or how can i fix/find, how with examples.

I'll show you my fallout minigame maybe u see here one of the loops:
( also there was 31/50 players online... and the server freezed :/ ).

FALLOUT DEFINES:
PHP код:
#define    InFallout(%0)                         GetPVarInt(%0,"In_Fallout")
#define FALLOUT_COUNT                         30
#define    MIN_FALLOUT_PLAYER                    2 
FALLOUT VARIABLES:
PHP код:
new Iterator:_JucatoriFallout<MAX_PLAYERS>;
new
    
Float:fallpos[ 3 ],
    
fObjects[ 76 ],
    
fall_objects = 76,
    
fall_players = false,
    
bool: FalloutStarted = false,
    
bool: FalloutRun = false,
    
FalloutStartTimer = -1,
    
falloutcount = FALLOUT_COUNT,
    
FalloutDeathTimer,
    
PlayerText:fall_td[ MAX_PLAYERS ],
    
PlayerText:derby_td[ MAX_PLAYERS ],
    
f_object
;
new 
Float:falloutpos[ 15 ][ 4 ] =
{
    { -
988.0902,-659.1328,261.1797,218.4480 },
    { -
977.8398,-658.9387,261.1795,180.0 },
    { -
966.5896,-659.5820,261.1799,180.0 },
    { -
958.3835,-659.4771,261.1799,145.0 },
    { -
958.1046,-671.3028,261.1804,90.0 },
    { -
957.2604,-684.1865,261.1788,90.0 },
    { -
957.6481,-697.5299,261.1801,45.0 },
    { -
970.7908,-697.2638,261.1800,0.0 },
    { -
981.4674,-697.1113,261.1799,0.0 },
    { -
976.2013,-679.8033,261.1793,347.2058 },
    { -
970.8993,-667.8923,261.1787,90.0 },
    { -
981.1204,-669.2873,261.1794,235.9321 },
    { -
964.1179,-680.9289,261.1798,97.1868 },
    { -
969.1664,-690.2943,261.1792,0.0 },
    { -
980.8322,-681.1248,261.1800,0.0 }
};
enum PlayerData
{
    
Falloutwon
}; 
FALLOUT COMMANDS:
PHP код:
CMD:fallout( playerid, params[ ] )
{
    if( 
InFallout( playerid ) )
        return 
SendError( playerid, "You are already signed in Fallout Minigame !" );
    if( 
FalloutRun == true )
        return 
SendError( playerid, "The Fallout Minigame is already started !" );
    if( !
FalloutStarted )
    {
        
StartFallout( );
            
JoinFallout( playerid );
    }
    else 
JoinFallout( playerid );
     
ResetSomeVars( playerid );
    return 
1;
}
CMD:lfallout(playerid)
{
     if( !
InFallout( playerid ) )
         return 
SendError( playerid, "You are not signed up in the Fallout Minigame !" );
    
fall_players --;
    
SetPVarInt( playerid, "In_Fallout", 0 );
    
SetPlayerVirtualWorld( playerid, 0 );
    
SetPlayerHealth( playerid, 100 );
    
SpawnPlayer( playerid );
    
eString[ 0 ] = EOS;
    
format( eString, sizeof( eString ), "- Fallout - {%06x}%s(%d) {00CC00}has left the {FFFFFF}'{C0C0C0}/fallout{FFFFFF}' {00CC00}minigame.", GetPlayerColor( playerid ) >>> 8, PlayerName( playerid ), playerid );
    
SendClientMessageToAll( 0x00CC00FF, eString );
    
Iter_Remove(_JucatoriFallout, playerid);
    
PlayerInfo[ playerid ][ Ignore_Goto ] = 0;
    
PlayerInfo[ playerid ][ Ignore_Get ] = 0;
    
SpawnPlayer( playerid );
     return ( 
1 );
} 
OnPlayerDisconnect
PHP код:
/* Fallout Minigame */
    
if( InFallout( playerid ) )
    {
        
format( eString, sizeof( eString ),"- Fallout - {%06x}%s(%d) {00CC00}lost the {FFFFFF}'{C0C0C0}/fallout{FFFFFF}' {00CC00}round. Reason: Disconnected.", GetPlayerColor( playerid ) >>> 8, PlayerName( playerid ), playerid );
        
SendClientMessageToAll( 0x00CC00FF, eString );
        
Iter_Remove(_JucatoriFallout, playerid);
        
DeletePVar( playerid, "In_Fallout" );
    } 
FALLOUT FUNCTIONS
PHP код:
function FalloutCheck( )
{
    if( 
fall_objects == 1 && fall_players > 1 )
    {
        
SendClientMessageToAll( 0x00CC00FF, "- Fallout - The {FFFFFF}'{C0C0C0}/fallout{FFFFFF}' {00CC00}round has finished. Reason: Equality." );
        
DeleteFallout( );
        return 
1;
    }
    new 
Float:FPos[ 3 ];
    if( 
fall_players == MIN_FALLOUT_PLAYER - 1 )
    {
        if( !
fall_players )
        {
            
SendClientMessageToAll( 0x00CC00FF, "- Fallout - The {FFFFFF}'{C0C0C0}/fallout{FFFFFF}' {00CC00}round has finished sucesfully." );
            
DeleteFallout();
            return ( 
1 );
        }
        
INFO_TD_MSG( FalloutWinner( ), 5000, "~w~You finished the ~r~~h~Fallout Minigame~w~~n~\
          ~y~~h~Reward: ~g~~h~~h~400 ~w~Score, ~g~~h~~h~$~r~~h~450,000~w~." 
);
        
GivePlayerMoney( FalloutWinner( ), 450000 );
        
SetPlayerScore( FalloutWinner( ), GetPlayerScore( FalloutWinner( ) ) + 400 );
        
eString[ 0 ] = EOS;
        
format( eString, sizeof( eString ), "- Fallout - {%06x}%s(%d) {00CC00}has won the {FFFFFF}'{C0C0C0}/fallout{FFFFFF}' {00CC00}minigame.", GetPlayerColor( FalloutWinner() ) >>> 8, PlayerName( FalloutWinner() ), FalloutWinner() );
        
SendClientMessageToAll( 0x00CC00FF, eString );
        
DeleteFallout( );
        return 
1;
    }
    for( new 
i; i < MAX_PLAYERS; i ++ )
    {
        if( 
InFallout( i ) )
        {
              
FreshFalloutTD( );
            
GetPlayerPos( i, FPos[ 0 ], FPos[ 1 ], FPos[ 2 ] );
            if( 
FPos[ 2 ] < 250.0 ) return cmd_lfallout( i );
        }
    }
    return 
1;
}
function 
FalloutGameUpdate( )
{
    if( 
FalloutStarted == false || FalloutRun == false )
        return 
0;
    
FalloutCheck( );
    
refunction:
     
f_object = fObjects[ random( 75 ) ];
    
GetDynamicObjectPos( f_object, fallpos[ 0 ], fallpos[ 1 ], fallpos[ 2 ] );
    if( 
fallpos[ 2 ] != 260.0 ) goto refunction;
    
GetDynamicObjectRot( f_object, fallpos[ 0 ], fallpos[ 1 ], fallpos[ 2 ] );
    
SetDynamicObjectRot( f_object, fallpos[ 0 ] + 6.0, fallpos[ 1 ], fallpos[ 2 ] );
    
SetTimerEx( "LeftFalloutObject", 900, false, "i", f_object );
    return 
1;
}
function 
LeftFalloutObject( f_randobject )
{
    if( !
fall_objects )
        return 
0;
    
GetDynamicObjectPos( f_randobject, fallpos[ 0 ], fallpos[ 1 ], fallpos[ 2 ] );
    
MoveDynamicObject( f_randobject, fallpos[ 0 ], fallpos[ 1 ], fallpos[ 2 ] - 100, 10.0, 0, 0, 0 );
    
fall_objects --;
    return 
1;
}
stock DeleteFallout( )
{
    
SendClientMessageToAll( 0x00CC00FF, "- Fallout - The {FFFFFF}'{C0C0C0}/fallout{FFFFFF}' {00CC00}minigame is now finished." );
    if( 
FalloutStarted == false )
        return 
0;
    for( new 
i; i < MAX_PLAYERS; i++ )
    {
        if( 
InFallout( i ) )
         {
            
SetPVarInt( i, "In_Fallout", 0 );
            
SetPlayerVirtualWorld( i, 0 );
            
PlayerTextDrawHide( i, fall_td[ i ] );
            
SpawnPlayer( i );
        }
        
KillTimer( FalloutStartTimer );
        
KillTimer( FalloutDeathTimer );
        
falloutcount = FALLOUT_COUNT;
        
FalloutStartTimer = -1;
        
FalloutRun = false;
        
FalloutStarted = false;
    }
    for( new 
i = 0; i < 76; i++ )
        
DestroyDynamicObject( fObjects[ i ] );
    return ( 
1 );
}
stock FalloutWinner( )
{
    for( new 
i; i < MAX_PLAYERS; i++ )
        if( 
InFallout( i ) )
            return 
i;
    return 
1;
}
stock ConvertIntToDate( All, &Hour, &Minute, &Second )
{
    
Hour = All / 3600;
    
All = All - (Hour*3600);
    
Minute = All / 60;
    
All = All - (Minute*60);
    
Second = All;
    
All = All - Second;
}
LoadFalloutMap() {
    
fObjects[0] = CreateDynamicObject(1697,-984.5000000,-659.2000100,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[1] = CreateDynamicObject(1697,-988.9660000,-659.2000100,260.0,31.7610000,0.0,0.0, 3);
    
fObjects[2] = CreateDynamicObject(1697,-980.0332000,-659.1992200,260.0,31.7610000,0.0,0.0, 3);
    
fObjects[3] = CreateDynamicObject(1697,-975.5673800,-659.1992200,260.0,31.7610000,0.0,0.0, 3);
    
fObjects[4] = CreateDynamicObject(1697,-971.1015600,-659.1992200,260.0,31.7610000,0.0,0.0, 3);
    
fObjects[5] = CreateDynamicObject(1697,-966.6357400,-659.1992200,260.0,31.7610000,0.0,0.0, 3);
    
fObjects[6] = CreateDynamicObject(1697,-962.1699200,-659.1992200,260.0,31.7610000,0.0,0.0, 3);
    
fObjects[7] = CreateDynamicObject(1697,-957.7031200,-659.1992200,260.0,31.7610000,0.0,0.0, 3);
    
fObjects[8] = CreateDynamicObject(1697,-984.5000000,-664.5600000,260.0,31.7610000,0.0,0.0, 3);
    
fObjects[9] = CreateDynamicObject(1697,-988.9660000,-669.9199800,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[10] = CreateDynamicObject(1697,-988.9660000,-675.2799700,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[11] = CreateDynamicObject(1697,-988.9660000,-680.6399500,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[12] = CreateDynamicObject(1697,-988.9660000,-685.9999400,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[13] = CreateDynamicObject(1697,-988.9660000,-691.3599200,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[14] = CreateDynamicObject(1697,-988.9660000,-696.7199100,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[15] = CreateDynamicObject(1697,-988.9658200,-664.5595700,260.0,31.7610000,0.0,0.0, 3);
    
fObjects[16] = CreateDynamicObject(1697,-980.0341800,-664.5595700,260.0,31.7610000,0.0,0.0, 3);
    
fObjects[17] = CreateDynamicObject(1697,-975.5683600,-664.5605500,260.0,31.7610000,0.0,0.0, 3);
    
fObjects[18] = CreateDynamicObject(1697,-971.1025400,-664.5605500,260.0,31.7610000,0.0,0.0, 3);
    
fObjects[19] = CreateDynamicObject(1697,-966.6367200,-664.5615200,260.0,31.7610000,0.0,0.0, 3);
    
fObjects[20] = CreateDynamicObject(1697,-962.1709000,-664.5615200,260.0,31.7610000,0.0,0.0, 3);
    
fObjects[21] = CreateDynamicObject(1697,-957.7050800,-664.5625000,260.0,31.7610000,0.0,0.0, 3);
    
fObjects[22] = CreateDynamicObject(1697,-984.5000000,-669.9199800,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[23] = CreateDynamicObject(1697,-984.5000000,-675.2799700,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[24] = CreateDynamicObject(1697,-984.5000000,-680.6399500,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[25] = CreateDynamicObject(1697,-984.5000000,-685.9999400,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[26] = CreateDynamicObject(1697,-984.5000000,-691.3599200,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[27] = CreateDynamicObject(1697,-984.5000000,-696.7199100,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[28] = CreateDynamicObject(1697,-980.0351600,-669.9199200,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[29] = CreateDynamicObject(1697,-980.0361300,-675.2802700,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[30] = CreateDynamicObject(1697,-980.0371100,-680.6406200,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[31] = CreateDynamicObject(1697,-980.0380900,-686.0009800,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[32] = CreateDynamicObject(1697,-980.0390600,-691.3613300,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[33] = CreateDynamicObject(1697,-980.0400400,-696.7216800,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[34] = CreateDynamicObject(1697,-975.5693400,-669.9218700,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[35] = CreateDynamicObject(1697,-975.5703100,-675.2832000,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[36] = CreateDynamicObject(1697,-975.5712900,-680.6445300,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[37] = CreateDynamicObject(1697,-975.5722700,-686.0058600,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[38] = CreateDynamicObject(1697,-975.5732400,-691.3671900,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[39] = CreateDynamicObject(1697,-975.5742200,-696.7285200,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[40] = CreateDynamicObject(1697,-971.1035200,-669.9218700,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[41] = CreateDynamicObject(1697,-971.1044900,-675.2832000,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[42] = CreateDynamicObject(1697,-971.1054700,-680.6445300,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[43] = CreateDynamicObject(1697,-971.1064500,-686.0058600,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[44] = CreateDynamicObject(1697,-971.1074200,-691.3671900,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[45] = CreateDynamicObject(1697,-971.1084000,-696.7285200,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[46] = CreateDynamicObject(1697,-971.1035200,-669.9218700,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[47] = CreateDynamicObject(1697,-971.1044900,-675.2832000,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[48] = CreateDynamicObject(1697,-971.1054700,-680.6445300,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[49] = CreateDynamicObject(1697,-971.1064500,-686.0058600,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[50] = CreateDynamicObject(1697,-971.1074200,-691.3671900,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[51] = CreateDynamicObject(1697,-971.1084000,-696.7285200,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[52] = CreateDynamicObject(1697,-966.6377000,-669.9238300,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[53] = CreateDynamicObject(1697,-966.6386700,-675.2861300,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[54] = CreateDynamicObject(1697,-966.6396500,-680.6484400,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[55] = CreateDynamicObject(1697,-966.6406200,-686.0107400,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[56] = CreateDynamicObject(1697,-966.6416000,-691.3730500,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[57] = CreateDynamicObject(1697,-966.6425800,-696.7353500,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[58] = CreateDynamicObject(1697,-966.6377000,-669.9238300,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[59] = CreateDynamicObject(1697,-966.6386700,-675.2861300,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[60] = CreateDynamicObject(1697,-966.6396500,-680.6484400,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[61] = CreateDynamicObject(1697,-966.6406200,-686.0107400,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[62] = CreateDynamicObject(1697,-966.6416000,-691.3730500,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[63] = CreateDynamicObject(1697,-966.6425800,-696.7353500,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[64] = CreateDynamicObject(1697,-962.1718700,-669.9238300,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[65] = CreateDynamicObject(1697,-962.1728500,-675.2861300,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[66] = CreateDynamicObject(1697,-962.1738300,-680.6484400,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[67] = CreateDynamicObject(1697,-962.1748000,-686.0107400,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[68] = CreateDynamicObject(1697,-962.1757800,-691.3730500,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[69] = CreateDynamicObject(1697,-962.1767600,-696.7353500,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[70] = CreateDynamicObject(1697,-957.7070300,-669.9259000,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[71] = CreateDynamicObject(1697,-957.7089800,-675.2892500,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[72] = CreateDynamicObject(1697,-957.7109400,-680.6525900,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[73] = CreateDynamicObject(1697,-957.7128900,-686.0159300,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[74] = CreateDynamicObject(1697,-957.7148400,-691.3792700,260.0,31.7670000,0.0,0.0, 3);
    
fObjects[75] = CreateDynamicObject(1697,-957.7168000,-696.7426100,260.0,31.7670000,0.0,0.0, 3);
    return ( 
1 );
}
function 
FalloutCounter()
{
    
falloutcount--;
    
format(eString, sizeof(eString), "~w~Fallout starts in:~n~~r~~h~%02i ~w~seconds.", falloutcount );
    for(new 
i; i < MAX_PLAYERS; i++) {
        if(
InFallout(i)) GameTextForPlayer(i, eString, 2000, 4);
    }
    if(!
falloutcount)
    {
        if(
fall_players < MIN_FALLOUT_PLAYER) return DeleteFallout();
        for(new 
i; i < MAX_PLAYERS; i++)
        {
            if(
InFallout(i))
            {
                
GameTextForPlayer(i, "~w~Fallout~n~~g~~h~~h~Let's Play !", 2000, 4);
                
TogglePlayerControllable(i, true);
                
SetCameraBehindPlayer(i);
                
PlayerTextDrawShow(i, fall_td[i]);
            }
        }
        
KillTimer(FalloutStartTimer);
        
FalloutRun = true;
        
FalloutDeathTimer = SetTimer("FalloutGameUpdate", 1000, true);
    }
    return ( 
1 );
}
function 
StartFallout()
{
    if(
FalloutStarted == true) return ( 0 );
    
FalloutStarted = true;
    
LoadFalloutMap();
    
fall_objects = 76;
    
fall_players = false;
    return ( 
1 );
}
function 
JoinFallout(playerid)
{
    if(
FalloutStarted == false)
        return ( 
0 );
    if(
FalloutRun == true)
        return ( 
0 );
    if(
FalloutStartTimer == -1)
    
FalloutStartTimer = SetTimer("FalloutCounter", 1000, true);
    new 
r = random(sizeof(falloutpos));
    
SetPlayerPos(playerid, falloutpos[r][0], falloutpos[r][1], falloutpos[r][2]);
    
SetPlayerFacingAngle(playerid, falloutpos[r][3]);
    
SetPlayerVirtualWorld(playerid, 3);
    
SetCameraBehindPlayer(playerid);
    
//SetPlayerCameraLookAt(playerid, falloutpos[r][0], falloutpos[r][1], falloutpos[r][2]);
    //SetPlayerCameraPos(playerid, falloutpos[r][0], falloutpos[r][1], falloutpos[r][2]+25);
    
TogglePlayerControllable(playerid, false);
    
SetPVarInt(playerid, "In_Fallout", 1);
    
fall_players ++;
    
Iter_Add(_JucatoriFallout, playerid);
    
eString[ 0 ] = EOS;
    
format( eString, sizeof( eString ), "- Fallout - {%06x}%s(%d) {00CC00}has joined the {FFFFFF}'{C0C0C0}/fallout{FFFFFF}' {00CC00}minigame. ( %d/15 )", GetPlayerColor( playerid ) >>> 8, PlayerName( playerid ), playerid, fall_players );
    
SendClientMessageToAll ( 0x00CC00FF, eString );
    return ( 
1 );
}
FreshFalloutTD()
{
    if(
FalloutRun == false)
        return ( 
0 );
    for( new 
ix = 0; ix < MAX_PLAYERS; ix++ )
    {
        if( 
GetPVarInt( ix, "In_Fallout" ) )
        {
            new 
str[128] = EOS;
            
format(str, sizeof(str), "~w~Objects: ~r~~h~%i~n~~w~Players: ~r~~h~%i~w~/~g~~h~~h~15",fall_objects ,fall_players);
            
PlayerTextDrawSetString(ix, fall_td[ix], str);
        }
    }
    return ( 
1 );
} 
What is an infinite loop ? And how can i print to see if there's an infinite loop ?
Reply
#2

An infinite loop is, as the name suggests, an infinite loop that keeps repeating endlessly because the required value is never reached. An example for an infinite loop is;

pawn Код:
for(new i = 1; i < 0; i++) {

}
Initiation value is 1, and each time the loop repeats, it will add 1 to the value, making it a LOT higher than 0 and the value will never reach 0 or less unless you do it by code on another line. This will cause the script to crash after a while to end the loop.

You can't use print function to see if there's an infinite loop as far as I am aware, you'll have to check each loop one by one unless someone else has a better method of it.
Reply
#3

Yeah buddy, but i also don't know how to debug.
And in my GM i don't see something wrong..
Reply
#4

There are some of redundant variables in there. Since you are using a custom foreach iterator you can pretty much rely on that alone. Instead of using a PVar to store whether the player is in the fallout you can use Iter_Contains and instead of incrementing and decrementing a variable to count the number of players you can use Iter_Count.
Reply
#5

Quote:
Originally Posted by Vince
Посмотреть сообщение
There are some of redundant variables in there. Since you are using a custom foreach iterator you can pretty much rely on that alone. Instead of using a PVar to store whether the player is in the fallout you can use Iter_Contains and instead of incrementing and decrementing a variable to count the number of players you can use Iter_Count.
Ok, done. But server sometimes freeze and '/fallout' minigame isn't started. How about this ? )
Reply
#6

Quote:
Originally Posted by Rufio
Посмотреть сообщение
An infinite loop is, as the name suggests, an infinite loop that keeps repeating endlessly because the required value is never reached. An example for an infinite loop is;

pawn Код:
for(new i = 1; i < 0; i++) {

}
Initiation value is 1, and each time the loop repeats, it will add 1 to the value, making it a LOT higher than 0 and the value will never reach 0 or less unless you do it by code on another line. This will cause the script to crash after a while to end the loop.
This is not an infinite loop. Actually the inside of the loop is never going to be called since it asks if i is lower 0. Though it is never smaller than 0 because it starts with "1".
Reply
#7

Quote:
Originally Posted by SoLetsGO
Посмотреть сообщение
This is not an infinite loop. Actually the inside of the loop is never going to be called since it asks if i is lower 0. Though it is never smaller than 0 because it starts with "1".
It is an infinite loop, it will keep repeating until a value of < 0 is reached, which it will never reach.

Edit: My bad, it should've been > 0.
Reply


Forum Jump:


Users browsing this thread: