AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   register_touch toucher question (https://forums.alliedmods.net/showthread.php?t=117565)

ehha 02-02-2010 13:36

register_touch toucher question
 
If i have many classes, how can I set a wildcard for register_touch instead of:
PHP Code:

register_touch"sametype_class1",   "player""sametype_touch" );
register_touch"sametype_class2",   "player""sametype_touch" );
register_touch"sametype_class3",   "player""sametype_touch" );
...
register_touch"sametype_classN",   "player""sametype_touch" ); 

I see that "*" or "" is for any class.

joropito 02-02-2010 14:35

Re: register_touch toucher question
 
Quote:

Originally Posted by ehha (Post 1076265)
If i have many classes, how can I set a wildcard for register_touch instead of:
PHP Code:

register_touch"sametype_class1",   "player""sametype_touch" );
register_touch"sametype_class2",   "player""sametype_touch" );
register_touch"sametype_class3",   "player""sametype_touch" );
...
register_touch"sametype_classN",   "player""sametype_touch" ); 

I see that "*" or "" is for any class.

Use fakemeta

PHP Code:

register_forward(FM_Touch"sametype_touch"


Dr.G 02-02-2010 14:41

Re: register_touch toucher question
 
I would do like this...

PHP Code:

new const CLASSES[][] = { 
    
    
"CLASS#1"
    
"CLASS#2"
    
"CLASS#3" 


new const 
FORWARD_NAME[] = "fwd_Touch"
new const PLAYER[] = "player"

public plugin_init() 

    
    for (new 
0sizeof CLASSESi++) 
        
register_touch(CLASSES[i], PLAYER FORWARD_NAME
    
}

public 
fwd_TouchiEntid)
{
    
// ....



ehha 02-02-2010 14:43

Re: register_touch toucher question
 
I forgot to say many custom entity classes, I need to hook only the custom classes touch.
Is FM_Touch for any class?

A for looks like a alternative to wildcard, I'll use it if there's no wildcard variant, thanks :)

xPaw 02-02-2010 14:49

Re: register_touch toucher question
 
Sumthin' like this ?
Code:
register_touch( "*", "player", "sametype_touch" ); public sametype_touch( ... ) {     static wildcard[ ] = "sometype_class";         new szClassName[ 32 ];     pev( iEntity, pev_classname, szClassName, 31 );         if( equal( szClassName, wildcard, sizeof( wildcard ) ) ) {         // [ .. ]     } }

ehha 02-02-2010 15:26

Re: register_touch toucher question
 
Something like that, but now my novice brain's got some questions:

Is there a value for the 1st parameter of register_touch that does the same thing as xPaw's code? (instead of "*" somethign like "*sametype_class")

If not, witch one of this versions has a better performance?
PHP Code:

register_touch"sametype_class1",   "player""sametype_touch" );
register_touch"sametype_class2",   "player""sametype_touch" );
register_touch"sametype_class3",   "player""sametype_touch" );
...
register_touch"sametype_class100",   "player""sametype_touch" ); 

or
PHP Code:

register_touch"*",   "player""sametype_touch" );
{
 
//filter stuff with xPaw's code using sametype_class substring



Jack86 02-02-2010 15:35

Re: register_touch toucher question
 
Will
register_touch( "*", "player", "sametype_touch" )

register every touch player makes with everything around him ?

ehha 02-02-2010 15:53

Re: register_touch toucher question
 
Yup, that's what I understand from here:
http://www.amxmodx.org/funcwiki.php?go=func&id=463


All times are GMT -4. The time now is 07:26.

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