AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Removing ents with HAM (https://forums.alliedmods.net/showthread.php?t=105104)

alan_el_more 10-01-2009 08:02

Removing ents with HAM
 
Hi guys :D
I have another problem with ents -.-
Look the code:
PHP Code:

#include <amxmodx>
#include <engine>
#include <hamsandwich>

new const g_remove_entities[][] = 

    
"func_bomb_target",    
    
"info_bomb_target"
    
"hostage_entity",      
    
"monster_scientist"
    
"func_hostage_rescue"
    
"info_hostage_rescue",
    
"info_vip_start",      
    
"func_vip_safetyzone"
    
"func_escapezone",     
    
"func_buyzone"
}

public 
plugin_init() {
     for(new 
0;sizeof g_remove_entities;i++)
        
RegisterHam(Ham_Spawng_remove_entities[i], "fw_RemoveEnts")
}

public 
fw_RemoveEnts(ent)
{
    if(
is_valid_ent(ent))
        
remove_entity(ent)


The problem:
Do not remove the entities :S

Question:
What am I doing wrong?

Arkshine 10-01-2009 08:08

Re: Removing ents with HAM
 
Register them in precache().

xPaw 10-01-2009 08:17

Re: Removing ents with HAM
 
Also you dont need if(is_valid_ent(ent))

alan_el_more 10-01-2009 08:47

Re: Removing ents with HAM
 
If I do that I can not choose teams -.-

Arkshine 10-01-2009 08:49

Re: Removing ents with HAM
 
Because Ham sucks :p ; use FM_Spawn

alan_el_more 10-01-2009 09:01

Re: Removing ents with HAM
 
Thanks arkshine :D

Arkshine 10-01-2009 09:07

Re: Removing ents with HAM
 
Someone has already talked about that ( there is a thread somewhere by xPaw If I'm right ), it's because Ham will spawn all entities with the same internal class and not the classname. The player spawn entities and others entities related to the hostage ( don't remember which ) use the same internal class.

Using trie :

Code:
    #include <amxmodx>     #include <fakemeta>         new Trie:tEntities;     new gFwdId;         public plugin_precache ()     {         new const EntitiesToRemove[][] =         {             "func_bomb_target"   , "info_bomb_target",             "hostage_entity"     , "monster_scientist",             "func_hostage_rescue", "info_hostage_rescue",             "info_vip_start"     , "func_vip_safetyzone",             "func_escapezone"    , "func_buyzone"         }                 for ( new i = 0; i < sizeof EntitiesToRemove; i++ )         {             TrieSetCell( tEntities, EntitiesToRemove[ i ], true );         }                 gFwdId = register_forward( FM_Spawn, "Foward_Spawn" );     }         public Foward_Spawn( const Entity )     {         new ClassName[ 32 ];         pev( Entity, pev_classname, ClassName, charsmax( ClassName ) );             if ( TrieKeyExists( tEntities, ClassName ) )         {             engfunc( EngFunc_RemoveEntity, Entity );         }     }         public plugin_init ()     {         unregister_forward( FM_Spawn, gFwdId );         TrieDestroy( tEntities );     }

Exolent[jNr] 10-01-2009 10:36

Re: Removing ents with HAM
 
Quote:

Originally Posted by Arkshine (Post 949020)
Someone has already talked about that ( there is a thread somewhere by xPaw If I'm right ), it's because Ham will spawn all entities with the same internal class and not the classname. The player spawn entities and others entities related to the hostage ( don't remember which ) use the same internal class.

It was me!

http://forums.alliedmods.net/showthread.php?t=102400

xPaw 10-01-2009 10:44

Re: Removing ents with HAM
 
Quote:

Originally Posted by Exolent[jNr] (Post 949083)

Lies, it was me!

http://forums.alliedmods.net/showthread.php?t=93624

Exolent[jNr] 10-01-2009 10:45

Re: Removing ents with HAM
 
Quote:

Originally Posted by xPaw (Post 949092)

Mine is almost the exact same as the topic, yours is just water.


All times are GMT -4. The time now is 22:31.

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