Инфо из hamsandwich.inc:
/**
* Hooks the virtual table for the specified entity's class.
* An example would be: RegisterHam(Ham_TakeDamage, id, "player_hurt");
* Look at the Ham enum for parameter lists.
* Note: This will cause hooks for the entire internal class that the entity is
* not exclusively for the provided entity.
*
* @param function The function to hook.
* @param EntityId The entity classname to hook.
* @param callback The forward to call.
* @param post Whether or not to forward this in post.
* @return Returns a handle to the forward. Use EnableHamForward/DisableHamForward to toggle the forward on or off.
*/
native HamHook:RegisterHamFromEntity(Ham:function, EntityId, const Callback[], Post=0);
Синтаксис:
RegisterHamFromEntity(Ham:function, EntityId, const Callback[], Post=0
- Ham:function - Функция для сцепления
- EntityId - id объекта для сцепления
- const Callback[] - Вызываемая функция
- Post=0 - Pre/Post Функция будет вызвана До/Или после события.
Тип функции:
Native
Пример:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#define PLUGIN "[http://amxxmodx.ru] HamHook:RegisterHamFromEntity"
#define VERSION "1.0"
#define AUTHOR "Admin"
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /rw","reg_fwd")
}
public reg_fwd(id){
RegisterHamFromEntity(Ham_Player_Jump,id,"fwd_player_jump",0)
}
public fwd_player_jump(id){
client_print(id,print_chat,"You in jump")
}
Описание:
В данном примере регистрируется форвард для игрока, который будет вызываться если игрок находится в прыжке.
RegisterHamFromEntity(Ham_Player_Jump,id,"fwd_player_jump",0)
Но не сразу, а только после выполнения команды say /rw ( просто в чате напишите /rw) и после попробуйте прыгнуть. Игровой чат будет заспамлен фразой You in jump, при этом данный форвард будет срабатывать только для вас, то есть если другой игрок прыгнет, данный форвард не вызовется, так как был зарегистрирован только для вас.
Из hamsandwich.inc:
Hooks the virtual table for the specified entity's class