Raised This Month: $12 Target: $400
 3% 

[TUT] Touch Stuff


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
SAMURAI16
BANNED
Join Date: Sep 2006
Old 03-17-2007 , 08:52   [TUT] Touch Stuff
Reply With Quote #1

Today we will discuss about touch stuff.
We will talk about:
1. Touch with natives
2.
Forwards touch
3.
Block touch operation
4.
Fake touch

So, let's start


1. Touch with natives
Engine way:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>


public plugin_init() {
    
register_plugin("Touch Test","0.1","SAMURAI");
    
    
// now registers a touch action to a function. 
    
register_touch("touched","toucher","hook_touch"); 
}


public 
hook_touch(touched,toucher)
{
    if(
is_user_admin(toucher) && is_user_bot(touched))    
    {
        
client_print(0,print_chat,"kbooom")
    }
    


touched = Who are touched by Toucher

toucher = Who touch

If you want to filter touched / toucher
An example :
Only running hook_touch if a player touch something..
PHP Code:
register_touch("player","*","hook_touch"); 


2. Forwards touch:
Engine way:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>


public plugin_init() {
    
register_plugin("Touch test","0.1","SAMURAI");
    
    
}

// Called when two entities touch/collide. 
public pfn_touch(ptr,ptd)
{
    new 
classname[32]
    
entity_get_string(ptr,EV_SZ_classname,classname,31

    
    if ( 
equal(classname"hostage_entity") ) 
    {
        
client_print(0,print_chat,"damn touched");
        
// and other stuff
    
}




Fakemeta way:
PHP Code:
#include <amxmodx>
#include <fakemeta>

public plugin_init() {
    
register_plugin("Touch Test","0.1","SAMURAI");
    
    
register_forward(FM_Touch,"hook_touch");
}

public 
hook_touch(ptr,ptd)
{
    new 
classname[32]
    
pev(ptr,pev_classname,classname,31)
    
    
    if ( 
equal(classname"hostage_entity") ) 
    {
        
client_print(0,print_chat,"damn touched");
        
// and other stuff
    
}
    



3.
Block touch operation:

On Engine:
To block touch use return PLUGIN_HANDLED;

On Fakemeta:
use return FMRES_SUPERCEDE;

4. Fake Touch:
This will
simulates two entities colliding/touching.
Engine:
PHP Code:
fake_touch(Touched,Toucher
Fakemeta:
PHP Code:
dllfunc(DLLFunc_Touchtouchedtoucher


Last edited by SAMURAI16; 03-20-2007 at 11:14.
SAMURAI16 is offline
Send a message via MSN to SAMURAI16
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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