Raised This Month: $ Target: $400
 0% 

Solved [HELP] My created entity wont go.....remove doesnt work...pls help!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 07-16-2018 , 07:16   Re: [HELP] My created entity wont go.....remove doesnt work...pls help!
Reply With Quote #1

Quote:
Originally Posted by BANDIT228 View Post
i wanna remove mafuba. in line 128 of my code. and i would need to identify the one being hit to stun him.
i tried to clientprint ptr and ptd....but its quite confusion

i tried the line 130 till 140 with ptr and ptd.....both times it didnt dissapear.
so ptr would be normally correct and ptd would be the victim i wanna stun right?
You need to change the code

PHP Code:
public plugin_init()
{
    ...
    
register_forwardFM_Touch"@EntityTouch" );  
    ...
}

...

public @
EntityTouch(ptr,ptd)   //toucher+touched
{
    new 
classname[32]
   
    
pev(ptdr,pev_classname,classname,31)
   
   
    if ( 
equal(classname"mafuba") )
    {
       
        
phase2(ptd)
       
       
    }  
 
    return 
FMRES_HANDLED
}
 
phase2(ball)
{
   
    new 
Float:orig[3]
    
pev(ballpev_originorig)
   
   
    
//client_print(ball,print_chat,"jo");
    
set_task(2.0"removeEntity"ball);
}
 
public 
removeEntity(ptr,ptd)
{
    new 
classname[32]
   
    
pev(ptd,pev_classname,classname,31)
   
   
    if ( 
equal(classname"mafuba") && is_valid_ent(ptd) )
    {
        
remove_entity(ptd);
    }

=>

PHP Code:
public plugin_init()
{
    ...
    
register_touch("mafuba""*""Mafuba_Touch"); //This way, is will only run if the entity is "Mafuba"
    
...
}

...

public 
Mafuba_Touch(entid)
{
    if(!
pev_valid(ent))
        return
    if(!
is_user_alive(id)) //Check if the touched thing is a player or not
        
return

    if(
id == pev(entpev_owner)) //Prevent owner from touch it (Put yourself in your own trap is so silly)
        
return

    if(!
task_exists(ent+9999)) set_task(2.0"removeEntity"ent+9999); //Prevent from touching multiple time
}
 
public 
removeEntity(entremove_entity(ent-9999); //Shorten 
__________________
My plugin:

Last edited by Celena Luna; 07-16-2018 at 07:19.
Celena Luna 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 12:14.


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