AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   how to use RegisterHam (https://forums.alliedmods.net/showthread.php?t=217623)

1023168216 06-05-2013 05:24

how to use RegisterHam
 
I'm a green hand. I meet some problems.
I don't know how to use RegisterHam and register_forward and register_touch and register_think.
I need help~~~ I need some simple codes about these four~~~ Give me some,please.
because what I found about these four are all very difficult for me to understand.

TheDS1337 06-05-2013 05:36

Re: how to use RegisterHam
 
Code:

public plugin_init( )
        //                Offset,        ClassName, Function,              Post
        RegisterHam( Ham_Spawn, "player", "OnPlayerSpawn_Post", 1 );
        // Base Hook: Hook Entity when it's spawned

Code:

public plugin_init( )
        //                    Offset,                    Function,                Post
        register_forward( FM_ClientPutInServer, "OnClientPutInServer", 0 );
        // Engine Function: Hook when player puts in the server

Code:

register_touch same as FM_Touch
register_think same as FM_Think


claudiuhks 06-05-2013 05:57

Re: how to use RegisterHam
 
The third argument in register_forward should be an integral value, not a string.

TheDS1337 06-05-2013 06:33

Re: how to use RegisterHam
 
Quote:

Originally Posted by claudiuhks (Post 1964981)
The third argument in register_forward should be an integral value, not a string.

Fixed :D

fysiks 06-06-2013 00:07

Re: how to use RegisterHam
 
Look at existing example, tutorials, and plugins.

1023168216 06-09-2013 11:00

Re: how to use RegisterHam
 
About "register_touch"and"register_think"??? can you please give me a example?
And i also wanna get some explain about something in "fakemeta_const.inc"
for example:what does "FM_CmdStart" mean???
i see it in this:register_forward(FM_CmdStart,"fw_CmdStar t")

President 06-09-2013 12:22

Re: how to use RegisterHam
 
PHP Code:

RegisterHam(Ham_*, "entity's_classname""Name_Of_Function"1); // 1 - after forward execute
RegisterHam(Ham_*, "entity's_classname""Name_Of_Function"0); // 0 - before forward execute
RegisterHam(Ham_*, "entity's_classname""Name_Of_Function"); // nothing - before forward execute


register_touch("classname_1""classname_2""Name_Of_Function");
// Example: register_touch("weaponbox", "player", "Player_touchs_Weapon");
// this touch will be executed when the player touch the weapon
// sth you have to know: when entity1 touch entity2, entity2 touch entity1, so the forward is executed 2 times


register_think("classname""Name_Of_Function");


register_forward(FM_CmdStart"fwdcmdstart");
// generally executed when player press any key ( both mouse and keyboard :D )


// Use register_think() and register_touch() instead of registering forwards FM_Think and FM_Touch.
// They are much faster.
// However not everything in engine is faster than fakemeta 


TheDS1337 06-09-2013 13:47

Re: how to use RegisterHam
 
Those
Code:
RegisterHam(Ham_*, "entity's_classname", "Name_Of_Function", 0); // 0 - before forward execute RegisterHam(Ham_*, "entity's_classname", "Name_Of_Function"); // nothing - before forward execute
Are the same

President 06-09-2013 14:22

Re: how to use RegisterHam
 
Quote:

Originally Posted by DeagLe.Studio (Post 1967585)
Those
Code:

RegisterHam(Ham_*, "entity's_classname", "Name_Of_Function", 0); // 0 - before forward execute
RegisterHam(Ham_*, "entity's_classname", "Name_Of_Function"); // nothing - before forward execute

Are the same

Damn

fysiks 06-09-2013 19:11

Re: how to use RegisterHam
 
Quote:

Originally Posted by 1023168216 (Post 1967434)
About "register_touch"and"register_think"??? can you please give me a example?
And i also wanna get some explain about something in "fakemeta_const.inc"
for example:what does "FM_CmdStart" mean???
i see it in this:register_forward(FM_CmdStart,"fw_CmdStar t")

All of your questions are already answered elsewhere. Search.


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

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