AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved [HELP] My created entity wont go.....remove doesnt work...pls help! (https://forums.alliedmods.net/showthread.php?t=309168)

BANDIT228 07-16-2018 02:33

[HELP] My created entity wont go.....remove doesnt work...pls help!
 
https://pastebin.com/RB87V31E

hi there....hope u can help me cause i am going nuts...

@line100
i added a touch for the entity....it shall detect when the entity hits a player. IF so the player should be stunned.....the entity should dissapear and i want to spawn a explosion there.

explosion and stuff aint atm....

i am a bit confused with the touched and the toucher.....tried to identify them with client prints...
thing is when i reactive line 127 the game crashes 2 seconds after the touch........
i added a ISValid and the entity name........then it doesnt crash anymore but the entity wont dissapear...


can someone pls help here? why wont that stupid entity be gone? and if someone can help with a stun that would be awesome aswell.....

appreciate the help.

Celena Luna 07-16-2018 05:56

Re: [HELP] My created entity wont go.....remove doesnt work...pls help!
 
PHP Code:

register_touch("worldspawn""capsule_jar""@Touch_Jar"

should be

PHP Code:

register_touch("capsule_jar""*""@Touch_Jar"

also if you used FM_Touch then use it with capsule_jar too

PHP Code:

public @EntityTouch(ptr,ptd)   //toucher+touched
{
new 
classname[32]
   
pev(ptr,pev_classname,classname,31)
   
   
if ( 
equal(classname"capsule_jar") )
{
//Code here



BANDIT228 07-16-2018 06:07

Re: [HELP] My created entity wont go.....remove doesnt work...pls help!
 
thx and yeah that would solve problem number 3^^ i can add a pev sequence for that.

but what about the stun? what about the entity that wont dissapear when i tell her to?


the flying entitys are mafubaentity and mafubaentityphase2

when mafuba entity touches a player....that one should freeze. and then there should spawn the mafubaentityphase2 and that should go where i aim.....and when that hits the ground near a mafuba_jar entity something should happen....



i know its sure a bit complex if you dont get the background.
https://youtu.be/T7spJPq5DiY?t=175
that video should help.

mafuba jar is the little bottle. you can spawn that via rightclick. works perfectly. even can get destroyed. mafubaentity is the first beam that goes to a enemy.then the enemy should be stunned. some effects and stuff....then mafubaentityphase2 should spawn. entity1 is gone till that. and you aim phase2 entity to the bottle(mafuba jar). camera of the victim should be forced onto that entity.....

if anyone could help that would be awesome..cause that project really gotten to big.....but i want it to be done....for me...and for the community.

Ghosted 07-16-2018 06:32

Re: [HELP] My created entity wont go.....remove doesnt work...pls help!
 
Last time i've seen people using @ before function name. Any meaning?

BANDIT228 07-16-2018 06:35

Re: [HELP] My created entity wont go.....remove doesnt work...pls help!
 
can i get some usefull replies pls?:D

and no it doesnt have any meaning...

Celena Luna 07-16-2018 06:58

Re: [HELP] My created entity wont go.....remove doesnt work...pls help!
 
Quote:

Originally Posted by BANDIT228 (Post 2603966)
can i get some usefull replies pls?:D

and no it doesnt have any meaning...

Hey, that rude. No one want to help a rude person :/

Anyway, I am not sure if "capsule_jar" or "mafuba" is the one you want to remove.
Also

PHP Code:

public @Touch_Jar(ptrptd//ptr is the entity ID & ptd is the player/object ID that touch 

P/S: How old is this kind of writing is? I have not since this kind of writing for a long time

BANDIT228 07-16-2018 07:00

Re: [HELP] My created entity wont go.....remove doesnt work...pls help!
 
sorry^^ wasnt meant to offend anyone. thats why i placed the smiley;)
and it only aimed for the question about the @^^


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?

Celena Luna 07-16-2018 07:16

Re: [HELP] My created entity wont go.....remove doesnt work...pls help!
 
Quote:

Originally Posted by BANDIT228 (Post 2603970)
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 


BANDIT228 07-16-2018 07:18

Re: [HELP] My created entity wont go.....remove doesnt work...pls help!
 
o.O ok gonna try that

thx buddy!. gonna tell you later if it worked

in case that works....


i would need that the second entity...its name gonna be mafubaphase2

will detect if its hits the ground/wall or if it hits the ground/wall near 10meters of the entity mafuba_jar
so these two cases.....

can u help here aswell? sorry to bother..... but i am on this since weeks....and not as experienced as i should be>_>
you are already on my credit list;)

Natsheh 07-16-2018 07:37

Re: [HELP] My created entity wont go.....remove doesnt work...pls help!
 
Quote:

Originally Posted by Ghosted (Post 2603964)
Last time i've seen people using @ before function name. Any meaning?

@ = at , its for readability, means its a forward.

OP :
Instead of removing the entitiy instantly give it a the flag FL_KILLME
No need to set task.


All times are GMT -4. The time now is 10:08.

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