Thread: [Solved] Prevent double looping
View Single Post
Author Message
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-16-2018 , 07:20   Prevent double looping
Reply With Quote #1

Hi,

How can I prevent using a for() loop inside another for() loop, lol.
This is my current code
PHP Code:
public OnNewRound( )
{
    new 
Float:fOrigin], WeaponEntity;
    
    for( new 
i=1sizeof g_szWeaponsi++ )
    {
        if( 
SsGetOriginfOrigin ) )
        {
            if( 
g_szWeapons][ ] != EOS )
            {
                new 
WeaponBoxEntity OrpheuCallHandleCreateNamedEntityFuncIntClassNameString ) ;
                if( ! 
pev_validWeaponBoxEntity ) )
                {
                    continue;
                }
                
                
engfuncEngFunc_SetOriginWeaponBoxEntityfOrigin );
                
ExecuteHamHam_SpawnWeaponBoxEntity );
                
                
WeaponEntity create_entityg_szWeapons] );
                
                if( ! 
pev_validWeaponEntity ) )
                {
                    
remove_entityWeaponBoxEntity );
                }

                
ExecuteHamHam_SpawnWeaponEntity );
                new 
WeaponID cs_get_weapon_idWeaponEntity );
                
                
OrpheuCallHandlePackWeaponFuncWeaponBoxEntityWeaponEntity );
                if( 
WeaponBoxModelsWeaponID ][ ] != EOS 
                { 
                    
engfuncEngFunc_SetModelWeaponBoxEntityWeaponBoxModelsWeaponID ] );
                } 

                
set_pdata_intWeaponBoxEntitym_pfnThinkCWeaponBoxKill_Address);
            }
        }
    }
    return 
PLUGIN_CONTINUE;

Here's the simpler version of the code:
PHP Code:
public OnNewRound( )
{
    new 
Float:fOrigin], WeaponEntity;
    
    for( new 
i=1sizeof g_szWeaponsi++ )
    {
        if( 
SsGetOriginfOrigin ) )
        {
            
// weapon is created here
        
}
    }
}
return 
PLUGIN_CONTINUE;

Now I need to add this inside that code
PHP Code:
new iArraySize ArraySizeg_aWeaponData );

for( new 
iiArraySizei++ )
{
    
ArrayGetArrayg_aWeaponDataig_iWeapons );

So I can retrieve the data from my array.

Thanks!!
__________________

Last edited by edon1337; 07-16-2018 at 13:23.
edon1337 is offline