AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   FM_Touch help me? (https://forums.alliedmods.net/showthread.php?t=240372)

felipemilralze 05-13-2014 23:51

FM_Touch help me?
 
can someone explain me but suffers FM Touch?

meTaLiCroSS 05-14-2014 00:05

Re: FM_Touch help me?
 
"Touch" is called whenever an entities touchs another entity (or world itself).

It has 2 arguments:

1) "pentTouched" which is the touched entity
2) "pentOther" which is the toucher, this one can be the world

Whenever "touch" is called, you must guess that 2 touch forwards will be called. The second callback will have the args flipped.

If ent1 touches ent2 and ent2 is not world:

Touch(ent1, ent2)
Touch(ent2, ent1)

Use register_touch instead of using Fakemeta's FM_Touch because you'll hook many touch callback, when you'll just check for an specific entity touch. (if it's the case)

swapped 05-14-2014 00:48

Re: FM_Touch help me?
 
can u post a list with entities and also an example :D ?

fysiks 05-14-2014 04:59

Re: FM_Touch help me?
 
Quote:

Originally Posted by swapped (Post 2137477)
can u post a list with entities and also an example :D ?

You could try searching . . . stop being lazy.

felipemilralze 05-14-2014 15:52

Re: FM_Touch help me?
 
Quote:

Originally Posted by meTaLiCroSS (Post 2137471)
"Touch" is called whenever an entities touchs another entity (or world itself).

It has 2 arguments:

1) "pentTouched" which is the touched entity
2) "pentOther" which is the toucher, this one can be the world

Whenever "touch" is called, you must guess that 2 touch forwards will be called. The second callback will have the args flipped.

If ent1 touches ent2 and ent2 is not world:

Touch(ent1, ent2)
Touch(ent2, ent1)

Use register_touch instead of using Fakemeta's FM_Touch because you'll hook many touch callback, when you'll just check for an specific entity touch. (if it's the case)


PHP Code:

public fw_touch(enttouched)
{
    if (!
pev_valid(ent)) 
        return 
FMRES_IGNORED
    
    
static entclass[32], entclass2[32]
    
pev(entpev_classnameentclasscharsmax(entclass))
    
pev(touchedpev_classnameentclass2charsmax(entclass2))

    if(
equali(entclass"amxx_pallets") && equali(entclass2"player") && is_user_alive(touched))
    {
                
set_pev(ent ,pev_solidSOLID_NOT)
    }
    return 
FMRES_IGNORED


I'm having trouble.

"ent" is doing fusion with the "touched"

Backstabnoob 05-14-2014 21:00

Re: FM_Touch help me?
 
What fusion? What do you want to do? Also as it's been said use register_touch instead, as you can directly pass the classnames in the parameters.

felipemilralze 05-14-2014 23:49

Re: FM_Touch help me?
 
Quote:

Originally Posted by Backstabnoob (Post 2137863)
What fusion? What do you want to do? Also as it's been said use register_touch instead, as you can directly pass the classnames in the parameters.

I registered but I just want to know the scope of the function, because this "touched" colliding with the "ent"

Fr33m@n 05-15-2014 10:29

Re: FM_Touch help me?
 
About touch i have some question about it.
i have 8 custom and different entities that can touch and i need to hook their touch.
Most of them are destroyed on touch.

what is the best ?
8 register_touch or hooking FM_Touch ?

Backstabnoob 05-15-2014 13:38

Re: FM_Touch help me?
 
Just hook register_touch 8 times, you will still save many calls because FM_Touch is called for ANY interaction between ANY two entities in the world.

Another option is to hook Ham_Touch with the toucher classname.

meTaLiCroSS 05-15-2014 21:32

Re: FM_Touch help me?
 
register_touch > Ham_Touch > FM_Touch

Keep in mind the usage of register_touch beside the others.


All times are GMT -4. The time now is 09:40.

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