Raised This Month: $ Target: $400
 0% 

Stock Help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Awesome_man
Senior Member
Join Date: May 2014
Location: singapore
Old 04-14-2016 , 06:49   Stock Help
Reply With Quote #1

What's wrong with the code below :-

I registered a command /destroy to destroy dispenser but it's not working whats wrong ?

PHP Code:
public destroy(iOwner)  
{
    new 
iEnt FM_NULLENT;  
    new 
iOwner peviEntpev_iuser2 ); 
        
      
bDispenserBuildiOwner ] = false;
           
set_peviEntpev_flagspeviEntpev_flags ) | FL_KILLME );  
    }
           
        
        
    }  
/*         
    ~~~~~~~~~~~~~~~~~~~~~~~
        Here is the stock 
    ~~~~~~~~~~~~~~~~~~~~~~~
*/


stock UTIL_DestroyDispensers( )
{
    new 
iEnt FM_NULLENT;
    
    while( ( 
iEnt find_ent_by_classiEntgDispenserClassname ) ) )
    {
        new 
iOwner peviEntpev_iuser2 );
        
        
bDispenserBuildiOwner ] = false;
        
set_peviEntpev_flagspeviEntpev_flags ) | FL_KILLME );
    }

someone please help.. thanks.

Last edited by Awesome_man; 04-14-2016 at 06:49.
Awesome_man is offline
simanovich
AlliedModders Donor
Join Date: Jun 2012
Location: Israel
Old 04-14-2016 , 09:06   Re: Stock Help
Reply With Quote #2

Why to set KILLME flag if you can just remove the ent?
__________________
simanovich is offline
SpannerSpammer
Member
Join Date: Mar 2006
Old 04-14-2016 , 18:48   Re: Stock Help
Reply With Quote #3

Here you go, you needed to compare the owner IDs.
Code:
stock public destroy( iOwner )
{
    new iEnt = FM_NULLENT;
    while( ( iEnt = find_ent_by_class( iEnt, gDispenserClassname ) ) )
    {
        if ( pev_valid( iEnt ))
        {
            new index = pev( iEnt, pev_iuser2 );
            if (  index == iOwner )
            {
                bDispenserBuild[ iOwner ] = false;
                set_pev( iEnt, pev_flags, pev( iEnt, pev_flags ) | FL_KILLME );
                break;
            }
        }
    }
}
_________________________________________


Quote:
Originally Posted by simanovich
Why to set KILLME flag if you can just remove the ent?
Both methods are valid, remove_entity() is just faster.
__________________
[NeoTF|DEV]SpannerSpammer-[AoE]-
NeoTF Development Team.
http://steamcommunity.com/groups/neotf

Last edited by SpannerSpammer; 04-14-2016 at 20:12.
SpannerSpammer 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 18:40.


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