AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Remove map specific ent (https://forums.alliedmods.net/showthread.php?t=54792)

bwgrubbs1 05-04-2007 03:15

Remove map specific ent
 
I am trying to remove one entity in particular in on particular map...

whats my problem ?

Code:
#include <amxmodx> #include <fakemeta> new curmap[32] curmap[] = get_mapname(curmap, 31) //problem on this line public plugin_init() {     register_plugin("Ent Remover", "1.1", "CSL")     register_event("REMOVE", "event_remove", "a", "1=0", "2=0") } public event_remove() {     remove_entity_by_classname("func_breakable")     remove_entity_by_classname("func_door_rotating")     remove_entity_by_classname("func_door") } stock remove_entity_by_classname(const classname[]) {     new ent = -1     while((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", classname)))     {         if(curmap[] = "de_aztec2") //problem on this line as well         {             if(pev(ent, pev_model) == 105) //SPECIFIC MODEL             {                 engfunc(EngFunc_RemoveEntity, ent)             }         }         else if(pev(ent, pev_spawnflags) != 1)         {             engfunc(EngFunc_RemoveEntity, ent)         }     } }

I am trying to remove a specific model on a specific map. In this case model # 105 on map de_aztec2. The only problem is that its labeled as a wall...i want to remove just this one...not all the walls. LOL :) help would be +karma'd

pRED* 05-04-2007 03:34

Re: Remove map specific ent
 
Your problem is the string comparisons..

Strings cannot be compared using = because the are essentially an array of cells.

for the first error just remove the curmap[] = from that start and I think it should work fine.

Code:
new curmap[32] get_mapname(curmap,31)

And for the comparison use the equali function

Code:
if (equali(curmap,"de_aztec2"))

Vet 05-04-2007 20:06

Re: Remove map specific ent
 
Is there actually a REMOVE event ? I'm no expert, but I've never heard of it.

Also, for efficiency, make the plugin dependent on the desired map...

Place in the 'event_remove' routine or before registering the event
Code:


if (!equal(curmap, "de_aztec2"))
    return PLUGIN_HANDLED

Otherwise you're checking entities on undesired maps. Kind of a waste.

pRED* 05-04-2007 21:12

Re: Remove map specific ent
 
Lol yeah didn't notice that...

Pretty sure that event doesn't exist.

Just run the function in plugin_cfg on something similar that happens only on map start.
And yes check the map as early as possible, no point in searching for ents when you're not going to do anything with them

Zenith77 05-04-2007 23:23

Re: Remove map specific ent
 
Please note: some ents can only be deleted on plugin_precache() [check other plugins for more info].


All times are GMT -4. The time now is 06:43.

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