Quote:
Originally Posted by BANDIT228
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_forward( FM_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(ball, pev_origin, orig)
//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(ent, id)
{
if(!pev_valid(ent))
return
if(!is_user_alive(id)) //Check if the touched thing is a player or not
return
if(id == pev(ent, pev_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(ent) remove_entity(ent-9999); //Shorten
__________________