AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Using pfn_touch (https://forums.alliedmods.net/showthread.php?t=12796)

Cronck 04-25-2005 04:53

Using pfn_touch
 
Is it possible to use this to check if to players is tuching eachother?
And how do i use it?

More 04-25-2005 09:00

Code:
public pfn_touch (ptr, ptd) {   if ((ptr > 0) && (ptd > 0) && is_valid_ent(ptr) && is_valid_ent(ptd)) {     new classname_ptr[32], classname_ptd[32]     entity_get_string(ptr, EV_SZ_classname, classname_ptr, 31)     entity_get_string(ptd, EV_SZ_classname, classname_ptd, 31)     if (equal(classname_ptr, "player") && equal(classname_ptd, "player")) {       new name_ptr[32], name_ptd[32]       get_user_name(ptr, name_ptr, 31)       get_user_name(ptd, name_ptd, 31)       client_print(0, print_chat, "%s touched %s", name_ptr, name_ptd)     }   } }

v3x 04-25-2005 15:31

Would this work if a player attacked another teammate with a knife?

XxAvalanchexX 04-25-2005 15:33

No... what do you need knifeness for so badly?

v3x 04-25-2005 15:34

Bah, nothing.. I'll just go by my original idea.

Twilight Suzuka 04-28-2005 23:01

register_touch is better.

Cronck 04-29-2005 06:30

I really dont want to registrer an event, id rather use a native which tells if they're touching eachother at the moment its called

Twilight Suzuka 04-29-2005 13:00

It is not registering an event.

Code:
register_touch(classname[],classname[],function[])

It fuctions by calling the function you specify when two objects of the provided classname touch. It is exactly like pfn_touch, but instead of seeing if the classnames are what you want in SMALL, it does it in the module, where it is much faster.

The end result is you get when two SPECIFIC things touch, like two players, so you do not have to compare classnames all the time and waste CPU.


All times are GMT -4. The time now is 16:39.

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