AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   The Best Way to Remove (https://forums.alliedmods.net/showthread.php?t=308439)

PurposeLessx 06-20-2018 10:19

The Best Way to Remove
 
I want to remove some entities but I don't know the best way to remove.

Spoiler

raizo11 06-20-2018 13:18

Re: The Best Way to Remove
 
Code:

public remove_entity()
{
    new ent = -1;

    while ((ent = find_ent_by_class(ent, "func_bomb_target")))
    {
        remove_entity(ent);
    }
}


PurposeLessx 06-20-2018 13:41

Re: The Best Way to Remove
 
Otherwise I find another method to remove. Is it any problem about my method?

PHP Code:


new const szRemoveEntities[][] =  {
    
"func_bomb_target""func_escapezone""func_hostage_rescue""func_vip_safetyzone""info_vip_start",
    
"hostage_entity""info_bomb_target""func_buyzone","info_hostage_rescue""monster_scientist",
    
"player_weaponstrip""game_player_equip"
}

public 
plugin_cfg()
{
    
TrieDestroy(g_tRemoveEntities);
    
unregister_forward(FM_Spawng_iForwardSpawn0);
}

public 
plugin_precache()
{
    
g_tRemoveEntities TrieCreate();
    for(new 
0sizeof(szRemoveEntities); i++)
    {
        
TrieSetCell(g_tRemoveEntitiesszRemoveEntities[i], i);
    }
    
g_iForwardSpawn register_forward(FM_Spawn"FM_Spawn_Pre"false);
    
engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"func_buyzone"));
}

public 
FM_Spawn_Pre(ent)
{
    if(!
pev_valid(ent))
    {
        return 
1;
    }

    new 
classname[32];
    
get_entvar(entvar_classnameclassnamecharsmax(classname));

    if(
TrieKeyExists(g_tRemoveEntitiesclassname))
    {
        
engfunc(EngFunc_RemoveEntityent);
        return 
4;
    }
    return 
1;



Natsheh 06-20-2018 14:34

Re: The Best Way to Remove
 
Raizo he didnt ask how he asked whats the best method to remove entity also your code wont compile.

@OP hook entity spawn then remove it.


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

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