Author
|
Message
|
BANNED
|
03-17-2007
, 08:52
[TUT] Touch Stuff
|
#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_Touch, touched, toucher)
Last edited by SAMURAI16; 03-20-2007 at 11:14.
|
|
|
|