Raised This Month: $ Target: $400
 0% 

Solved Prevent double looping


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:28.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode