View Single Post
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-20-2013 , 08:33   Re: He-Grenade Game 1.1
Reply With Quote #16

Better to return -1 in Spawn forward then removing the entity.
Also, you don't need to remove all those entity, see in followinf example which ones are needed.
End, you could use a Trie for those classes.

PHP Code:
new Trie:g_tRemoveEntClasses;
new 
g_iFhDispatchSpawn;

public 
plugin_precache()
{
    new 
szRemoveEntClasses[][] = 
    {
        
"func_bomb_target""info_bomb_target"// de_
        
"func_hostage_rescue"// cs_
        
"func_escapezone"// es_
        
"func_vip_safetyzone"// as_
    
};
    
g_tRemoveEntClasses TrieCreate();
    for(new 
ii<sizeof(szRemoveEntClasses); i++)
    {
        
TrieSetCell(g_tRemoveEntClassesszRemoveEntClasses[i], 1);
    }

    
g_iFhDispatchSpawn register_forward(FM_Spawn"OnDispatchSpawn"0);
}

public 
OnDispatchSpawnent )
{
    new 
classname[32];
    
pev(entpev_classnameclassnamecharsmax(classname));
    if( 
TrieKeyExists(g_tRemoveEntClassesclassname) )
    {
        
forward_return(FMV_CELL, -1);
        return 
FMRES_SUPERCEDE;
    }
    return 
FMRES_IGNORED;
}

public 
plugin_init()
{
    
unregister_forward(g_iFhDispatchSpawn);
    
TrieDestroy(g_tRemoveEntClasses);

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline