Raised This Month: $51 Target: $400
 12% 

[SOLVED] Removing entities.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
gogicaa
Veteran Member
Join Date: Aug 2011
Location: //
Old 08-03-2012 , 07:51   [SOLVED] Removing entities.
Reply With Quote #1

Hello !
Im having some problems with removing entities.
When im spawning it, I defined its classname.
PHP Code:
set_pev(ents[num],pev_classname,"test_w"
And i want to remove all ents with that classname on round end.
PHP Code:
    while((ent fm_find_ent_by_class(ent"test_w")))
    {
        if(
pev_valid(ent))
        {
            
engfunc(EngFunc_RemoveEntityent)
        }
    } 
And it wont work.
Your help will be greatly appreciated. Thanks !

Last edited by gogicaa; 08-04-2012 at 11:21. Reason: solved
gogicaa is offline
Swaycher
Senior Member
Join Date: Feb 2009
Location: Arg/MyHome/PawnStudio
Old 08-03-2012 , 18:18   Re: Removing entities.
Reply With Quote #2

try with this:

PHP Code:
new ent

while ((ent engfunc(EngFunc_FindEntityByStringent"classname""test_w")))
        
engfunc(EngFunc_RemoveEntityent
__________________
Quote:
Originally Posted by fearAR View Post
Claro esta que no tengo idea de como verificar los diferentes cortes de ángulo.
http://forums.alliedmods.net/showthread.php?t=196349
Swaycher is offline
Send a message via MSN to Swaycher Send a message via Skype™ to Swaycher
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-03-2012 , 18:25   Re: Removing entities.
Reply With Quote #3

Quote:
Originally Posted by Swaycher View Post
try with this:

PHP Code:
new ent

while ((ent engfunc(EngFunc_FindEntityByStringent"classname""test_w")))
        
engfunc(EngFunc_RemoveEntityent
This is the same code as the one thread op has reported as not working.


Please show the whole code, your code is ok, so problem is somewhere else.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
gogicaa
Veteran Member
Join Date: Aug 2011
Location: //
Old 08-03-2012 , 19:48   Re: Removing entities.
Reply With Quote #4

PHP Code:
public spawn_pu(num)
{
    
num -= 50
    
if(get_pcvar_num(pu_enabled) && type[num]!=-2)
    {
        
ents[num] = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
        
        
set_pev(ents[num],pev_classname,"test_w")
        
set_pev(ents[num],pev_classname,classnames[type[num]])
        
engfunc(EngFunc_SetModel,ents[num],models[type[num]])
        
set_pev(ents[num],pev_body,num)    

        
set_pev(ents[num], pev_effects32)
        
set_pev(ents[num], pev_solidSOLID_BBOX)
        
set_pev(ents[num], pev_movetypeMOVETYPE_FLY)
        
set_pev(ents[num], pev_owner33)
        
        
set_pev(ents[num],pev_sequence,0)
        
set_pev(ents[num],pev_gaitsequence,0)
        
set_pev(ents[num],pev_framerate,1.0)

        
set_pev(ents[num],pev_origin,origins[num])    
    }

PHP Code:
public zp_fw_gamemodes_end()
{                
    while((
ent fm_find_ent_by_class(ent"test_w")))
    {
        if(
pev_valid(ent))
        {
            
engfunc(EngFunc_RemoveEntityent)
        }
    }

gogicaa is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-03-2012 , 20:02   Re: Removing entities.
Reply With Quote #5

You don't need to check if entity is valid.

Make sur that zp_fw_gamemodes_end is called by printing or logging something.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
gogicaa
Veteran Member
Join Date: Aug 2011
Location: //
Old 08-04-2012 , 05:57   Re: Removing entities.
Reply With Quote #6

I've tried this :
PHP Code:
public zp_fw_gamemodes_end()
{    
    
client_print (0print_chat "gamemode end")
    
    new 
ent 
    
    
while ((ent engfunc(EngFunc_FindEntityByStringent"classname""test_w"))) 
    {
        
engfunc(EngFunc_RemoveEntityent)
        
client_print (0print_chat "removing entities")
    }    

Gamemode end event works, but it wont print "removing entities" on round end.

Last edited by gogicaa; 08-04-2012 at 05:57.
gogicaa is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-04-2012 , 06:15   Re: Removing entities.
Reply With Quote #7

Try engine (shouldn't make any difference but to make sure :

PHP Code:
public zp_fw_gamemodes_end()
{
    new class[] = 
"test_w"
    
new ent find_ent_by_class(0, class)
    new 
checks 1
    client_print 
(0print_chat "gamemode end check #%d = %d (next checks in console)"checks++, ent)

    while( 
ent )
    {
        
remove_entity(ent)
        
ent find_ent_by_class(ent, class)
        
client_print (0print_console "gamemode end check #%d = %d"checks++, ent)
    }

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
gogicaa
Veteran Member
Join Date: Aug 2011
Location: //
Old 08-04-2012 , 07:20   Re: Removing entities.
Reply With Quote #8

Wont work , it always says "gamemode end check #1 = 0 (next checks in console)"
gogicaa is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-04-2012 , 07:33   Re: Removing entities.
Reply With Quote #9

Means there are no entity with this classname.

PHP Code:
        set_pev(ents[num],pev_classname,"test_w")
        
set_pev(ents[num],pev_classname,classnames[type[num]]) 
First line is useless.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 08-04-2012 at 07:34.
ConnorMcLeod is offline
gogicaa
Veteran Member
Join Date: Aug 2011
Location: //
Old 08-04-2012 , 08:03   Re: Removing entities.
Reply With Quote #10

Then how should i register it ? o.O
Whats wrong with my code ?
gogicaa is offline
Reply



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 15:25.


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