Ham Sandwich: различия между версиями
Nikita (обсуждение | вклад) |
Nikita (обсуждение | вклад) (→GetHamReturnStatus) |
||
(не показано 16 промежуточных версий этого же участника) | |||
Строка 1: | Строка 1: | ||
+ | [[Категория:AMX MOD X]] | ||
== hamsandwich.inc == | == hamsandwich.inc == | ||
=== RegisterHam === | === RegisterHam === | ||
− | + | Отлавливает событие в игровом мире. Список событий очень большой, их описание можно посмотреть в константах Ham Sandwich. Функция возвращает идентификатор созданного форварда, который можно использовать в функциях EnableHamForward/DisableHamForward. | |
native HamHook:RegisterHam(Ham:function, const EntityClass[], const Callback[], Post=0); | native HamHook:RegisterHam(Ham:function, const EntityClass[], const Callback[], Post=0); | ||
+ | |||
+ | {| class="wide" | ||
+ | |- | ||
+ | | '''function''' | ||
+ | | Функция (событие). Например убийство. | ||
+ | |- | ||
+ | | '''EntityClass''' | ||
+ | | Класс объектов с которым происходит событие | ||
+ | |- | ||
+ | | '''callback''' | ||
+ | | Вызываемая функция | ||
+ | |- | ||
+ | | '''post''' | ||
+ | | Функция будет вызвана До/Или после события. | ||
+ | |} | ||
'''Пример:''' | '''Пример:''' | ||
− | |||
− | + | Будет вызвана функция player_hurt, перед тем как игрок получит повреждение. | |
− | + | RegisterHam(Ham_TakeDamage, "player", "player_hurt", 0); | |
− | |||
− | |||
− | |||
=== RegisterHamFromEntity === | === RegisterHamFromEntity === | ||
− | + | Отлавливает событие в игровом мире для определенного [[энтити-объекты|энтити-объекта]] или игрока. | |
native HamHook:RegisterHamFromEntity(Ham:function, EntityId, const Callback[], Post=0); | native HamHook:RegisterHamFromEntity(Ham:function, EntityId, const Callback[], Post=0); | ||
− | + | {| class="wide" | |
− | + | |- | |
− | + | | '''function''' | |
− | + | | Событие для отлова | |
− | + | |- | |
+ | | '''EntityId''' | ||
+ | | id объекта | ||
+ | |- | ||
+ | | '''callback''' | ||
+ | | Функция, которая будет вызвана | ||
+ | |- | ||
+ | | '''post''' | ||
+ | | Функция будет вызвана До/Или после события | ||
+ | |} | ||
+ | |||
+ | Returns a handle to the forward. Use EnableHamForward/DisableHamForward to toggle the forward on or off. | ||
'''Пример:''' | '''Пример:''' | ||
− | RegisterHam(Ham_TakeDamage, id, "player_hurt"); | + | RegisterHam(Ham_TakeDamage, id, "player_hurt", 0); |
=== DisableHamForward === | === DisableHamForward === | ||
− | + | Запускает работу Ham форварда. Противоположность [[Ham_Sandwich#EnableHamForward|EnableHamForward]]. | |
native DisableHamForward(HamHook:fwd); | native DisableHamForward(HamHook:fwd); | ||
− | + | {| class="wide" | |
+ | |- | ||
+ | | '''fwd''' | ||
+ | | ID форварда для остановки. | ||
+ | |} | ||
=== EnableHamForward === | === EnableHamForward === | ||
− | + | Запускает работу Ham форварда. Противоположность [[Ham_Sandwich#DisableHamForward|DisableHamForward]]. | |
native EnableHamForward(HamHook:fwd); | native EnableHamForward(HamHook:fwd); | ||
− | + | ||
+ | {| class="wide" | ||
+ | |- | ||
+ | | '''fwd''' | ||
+ | | Идентификатор форварда (возвращаемое значение RegisterHam) | ||
+ | |} | ||
+ | |||
+ | '''Пример:''' | ||
+ | |||
+ | <pre> | ||
+ | new HamHook:g_fwdTakeDamage | ||
+ | |||
+ | public plugin_init() { | ||
+ | register_plugin(PLUGIN, VERSION, AUTHOR) | ||
+ | |||
+ | g_fwdTakeDamage = RegisterHam(Ham_TakeDamage,"player","damager",0) | ||
+ | |||
+ | register_clcmd("say /off","f_off") | ||
+ | register_clcmd("say /on","f_on") | ||
+ | } | ||
+ | public f_on(){ | ||
+ | EnableHamForward(g_fwdTakeDamage) | ||
+ | client_print(0,print_chat,"Forward TakeDamege is enable") | ||
+ | } | ||
+ | public f_off(){ | ||
+ | DisableHamForward(g_fwdTakeDamage) | ||
+ | client_print(0,print_chat,"Forward TakeDamege is desable") | ||
+ | } | ||
+ | public damager(victim, inflicator, attacker, Float:damage){ | ||
+ | if(!is_user_connected(attacker)) | ||
+ | return; | ||
+ | |||
+ | if(victim == attacker || !victim) | ||
+ | return; | ||
+ | |||
+ | client_print(0,print_chat,"Damage: %.1f health:%d",damage,get_user_health(victim)) | ||
+ | |||
+ | } | ||
+ | </pre> | ||
=== ExecuteHam === | === ExecuteHam === | ||
− | + | Выполняет виртуальную функцию на [[энтити-объекты|энтити-объекте]] или игроке. Смотрите список параметров. | |
native ExecuteHam(Ham:function, this, any:...); | native ExecuteHam(Ham:function, this, any:...); | ||
− | + | {| class="wide" | |
− | + | |- | |
+ | | '''function''' | ||
+ | | Функция из списка Ham_ | ||
+ | |- | ||
+ | | '''this''' | ||
+ | | id объекта к кому применяется функция | ||
+ | |- | ||
+ | | any:... | ||
+ | | Дополнительные параметры если есть | ||
+ | |} | ||
+ | |||
+ | '''Пример:''' | ||
+ | |||
+ | Пример респавнит игрока. | ||
+ | <pre> | ||
+ | public plugin_init() { | ||
+ | register_clcmd("say /spawn","spawn"); | ||
+ | } | ||
+ | public spawn(id){ | ||
+ | ExecuteHam( Ham_CS_RoundRespawn, id ); | ||
+ | } | ||
+ | </pre> | ||
=== ExecuteHamB === | === ExecuteHamB === | ||
− | + | Функция аналогична [[Ham_Sandwich#ExecuteHam|ExecuteHam]] за исключением того, что результат выполнения можно отловить. | |
native ExecuteHamB(Ham:function, this, any:...); | native ExecuteHamB(Ham:function, this, any:...); | ||
− | * | + | {| class="wide" |
− | + | |- | |
+ | | '''function''' | ||
+ | | Функция из списка Ham_* | ||
+ | |- | ||
+ | | '''this''' | ||
+ | | id объекта | ||
+ | |- | ||
+ | | '''ani:...''' | ||
+ | | Другие параметры (если есть) | ||
+ | |} | ||
+ | |||
+ | '''Пример:''' | ||
+ | |||
+ | Пример респавнит игрока и выводит сообщение. | ||
+ | <pre> | ||
+ | public plugin_init() { | ||
+ | register_clcmd("say resp","new_life") | ||
+ | RegisterHam(Ham_CS_RoundRespawn,"player","player_respawn") | ||
+ | } | ||
+ | |||
+ | public new_life(id){ | ||
+ | ExecuteHamB(Ham_CS_RoundRespawn,id) | ||
+ | return PLUGIN_HANDLED | ||
+ | } | ||
+ | |||
+ | public player_respawn(id){ | ||
+ | client_print(0,print_chat,"Ham_CS_RoundRespawn is hooked") | ||
+ | } | ||
+ | </pre> | ||
=== GetHamReturnStatus === | === GetHamReturnStatus === | ||
− | + | Проверяет статус определенного события. Полезно в случаях когда на сервере установлено два плагина, работающих с одним событием. | |
native GetHamReturnStatus(); | native GetHamReturnStatus(); | ||
− | + | '''Пример:''' | |
+ | |||
+ | Пример отправляет в чат нанесенный урон. | ||
+ | <pre> | ||
+ | public plugin_init() { | ||
+ | RegisterHam(Ham_TakeDamage,"player","damager",0); | ||
+ | } | ||
+ | |||
+ | public damager(victim, inflicator, attacker, Float:damage){ | ||
+ | |||
+ | if(GetHamReturnStatus() != HAM_SUPERCEDE){ | ||
+ | client_print(0,print_chat,"Damage: %.1f health:%d",damage,get_user_health(victim)); | ||
+ | } | ||
+ | } | ||
+ | </pre> | ||
=== GetHamReturnInteger === | === GetHamReturnInteger === | ||
Строка 68: | Строка 196: | ||
native GetHamReturnInteger(&output); | native GetHamReturnInteger(&output); | ||
− | + | {| class="wide" | |
+ | |- | ||
+ | | '''output''' | ||
+ | | The variable to store the value in. | ||
+ | |} | ||
=== GetHamReturnFloat === | === GetHamReturnFloat === | ||
Строка 74: | Строка 206: | ||
native GetHamReturnFloat(&Float:output); | native GetHamReturnFloat(&Float:output); | ||
− | + | {| class="wide" | |
+ | |- | ||
+ | | '''output''' | ||
+ | | The variable to store the value in. | ||
+ | |} | ||
=== GetHamReturnVector === | === GetHamReturnVector === | ||
Строка 80: | Строка 216: | ||
native GetHamReturnVector(Float:output[3]); | native GetHamReturnVector(Float:output[3]); | ||
− | + | {| class="wide" | |
+ | |- | ||
+ | | '''output''' | ||
+ | | The variable to store the value in. | ||
+ | |} | ||
=== GetHamReturnEntity === | === GetHamReturnEntity === | ||
Строка 86: | Строка 226: | ||
native GetHamReturnEntity(&output); | native GetHamReturnEntity(&output); | ||
− | + | {| class="wide" | |
+ | |- | ||
+ | | '''output''' | ||
+ | | The variable to store the value in. Will be -1 on null. | ||
+ | |} | ||
=== GetHamReturnString === | === GetHamReturnString === | ||
Строка 92: | Строка 236: | ||
native GetHamReturnString(output[], size); | native GetHamReturnString(output[], size); | ||
− | + | {| class="wide" | |
− | + | |- | |
+ | | '''output''' | ||
+ | | The buffer to store the string in. | ||
+ | |- | ||
+ | | '''size''' | ||
+ | | The string size of the buffer. | ||
+ | |} | ||
=== GetOrigHamReturnInteger === | === GetOrigHamReturnInteger === | ||
Строка 99: | Строка 249: | ||
native GetOrigHamReturnInteger(&output); | native GetOrigHamReturnInteger(&output); | ||
− | + | {| class="wide" | |
+ | |- | ||
+ | | '''output''' | ||
+ | | The variable to store the value in. | ||
+ | |} | ||
=== GetOrigHamReturnFloat === | === GetOrigHamReturnFloat === | ||
Строка 105: | Строка 259: | ||
native GetOrigHamReturnFloat(&Float:output); | native GetOrigHamReturnFloat(&Float:output); | ||
− | + | {| class="wide" | |
+ | |- | ||
+ | | '''output''' | ||
+ | | The variable to store the value in. | ||
+ | |} | ||
=== GetOrigHamReturnVector === | === GetOrigHamReturnVector === | ||
Строка 111: | Строка 269: | ||
native GetOrigHamReturnVector(Float:output[3]); | native GetOrigHamReturnVector(Float:output[3]); | ||
− | + | {| class="wide" | |
+ | |- | ||
+ | | '''output''' | ||
+ | | The variable to store the value in. | ||
+ | |} | ||
+ | |||
=== GetOrigHamReturnEntity === | === GetOrigHamReturnEntity === | ||
Gets the original return value of a hook for hooks that return entities. | Gets the original return value of a hook for hooks that return entities. | ||
native GetOrigHamReturnEntity(&output); | native GetOrigHamReturnEntity(&output); | ||
− | + | {| class="wide" | |
+ | |- | ||
+ | | '''output''' | ||
+ | | The variable to store the value in. -1 on null. | ||
+ | |} | ||
+ | |||
=== GetOrigHamReturnString === | === GetOrigHamReturnString === | ||
Строка 123: | Строка 291: | ||
native GetOrigHamReturnString(output[], size); | native GetOrigHamReturnString(output[], size); | ||
− | + | {| class="wide" | |
− | + | |- | |
+ | | '''output''' | ||
+ | | The buffer to store the string in. | ||
+ | |- | ||
+ | | size | ||
+ | | The size of the buffer. | ||
+ | |} | ||
+ | |||
=== SetHamReturnInteger === | === SetHamReturnInteger === | ||
Строка 130: | Строка 305: | ||
native SetHamReturnInteger(value); | native SetHamReturnInteger(value); | ||
− | + | {| class="wide" | |
+ | |- | ||
+ | | '''value''' | ||
+ | | The value to set the return to. | ||
+ | |} | ||
=== SetHamReturnFloat === | === SetHamReturnFloat === | ||
Sets the return value of a hook that returns a float. This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE. | Sets the return value of a hook that returns a float. This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE. | ||
native SetHamReturnFloat(Float:value); | native SetHamReturnFloat(Float:value); | ||
− | + | ||
+ | {| class="wide" | ||
+ | |- | ||
+ | | '''value''' | ||
+ | | The value to set the return to. | ||
+ | |} | ||
=== SetHamReturnVector === | === SetHamReturnVector === | ||
Строка 141: | Строка 325: | ||
native SetHamReturnVector(const Float:value[3]); | native SetHamReturnVector(const Float:value[3]); | ||
− | + | {| class="wide" | |
+ | |- | ||
+ | | '''value''' | ||
+ | | The value to set the return to. | ||
+ | |} | ||
=== SetHamReturnEntity === | === SetHamReturnEntity === | ||
Строка 147: | Строка 335: | ||
native SetHamReturnEntity(value); | native SetHamReturnEntity(value); | ||
− | + | {| class="wide" | |
+ | |- | ||
+ | | '''value''' | ||
+ | | The value to set the return to. | ||
+ | |} | ||
=== SetHamReturnString === | === SetHamReturnString === | ||
Строка 154: | Строка 346: | ||
native SetHamReturnString(const value[]); | native SetHamReturnString(const value[]); | ||
− | + | {| class="wide" | |
− | + | |- | |
+ | | '''value''' | ||
+ | | The value to set the return to. | ||
+ | |} | ||
=== SetHamParamInteger === | === SetHamParamInteger === | ||
Строка 161: | Строка 356: | ||
native SetHamParamInteger(which, value); | native SetHamParamInteger(which, value); | ||
− | + | {| class="wide" | |
− | + | |- | |
+ | | '''which''' | ||
+ | | Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this". | ||
+ | |- | ||
+ | | '''value''' | ||
+ | | The value to change it to. | ||
+ | |} | ||
=== SetHamParamFloat === | === SetHamParamFloat === | ||
− | + | Задает параметры отловленного события. Не имеет никакого эффекта, если отлов был после события (Post). | |
+ | Полезна, если требуется увеличить или уменьшить урон, получаемый игроком. | ||
+ | |||
native SetHamParamFloat(which, Float:value); | native SetHamParamFloat(which, Float:value); | ||
− | + | {| class="wide" | |
− | * | + | |- |
+ | | '''which''' | ||
+ | | Параметр, который нужно изменить | ||
+ | |- | ||
+ | | '''value''' | ||
+ | | Новое значение параметра | ||
+ | |} | ||
+ | |||
+ | '''Пример:''' | ||
+ | Уменьшаем урон, получаемый игроком в два раза. | ||
+ | |||
+ | '''4''' - параметр урона | ||
+ | |||
+ | <pre> | ||
+ | public plugin_init() { | ||
+ | RegisterHam(Ham_TakeDamage,"player","damager",0); | ||
+ | } | ||
+ | |||
+ | public damager(victim, inflicator, attacker, Float:damage){ | ||
+ | if(!is_user_connected(attacker)){ | ||
+ | return; | ||
+ | } | ||
+ | |||
+ | if(victim == attacker || !victim){ | ||
+ | return; | ||
+ | } | ||
+ | |||
+ | SetHamParamFloat(4, damage * 0.5); | ||
+ | } | ||
+ | </pre> | ||
=== SetHamParamVector === | === SetHamParamVector === | ||
− | + | Задает параметры отловленного события. Не имеет никакого эффекта, если отлов был после события (Post). Аналогична функции [[Ham_Sandwich#SetHamParamFloat|Ham_Sandwich]], за исключением того, что новые параметры задаются вектором. | |
native SetHamParamVector(which, const Float:value[3]); | native SetHamParamVector(which, const Float:value[3]); | ||
− | + | {| class="wide" | |
− | + | |- | |
+ | | '''which''' | ||
+ | | Параметр, который нужно изменить | ||
+ | |- | ||
+ | | '''value''' | ||
+ | | Новое значение параметра | ||
+ | |} | ||
=== SetHamParamEntity === | === SetHamParamEntity === | ||
Строка 182: | Строка 420: | ||
native SetHamParamEntity(which, value); | native SetHamParamEntity(which, value); | ||
− | + | {| class="wide" | |
− | + | |- | |
+ | | '''which''' | ||
+ | | Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this". | ||
+ | |- | ||
+ | | '''value''' | ||
+ | | The value to change it to. | ||
+ | |} | ||
=== SetHamParamString === | === SetHamParamString === | ||
− | + | Задает параметры отловленного события. Не имеет никакого эффекта, если отлов был после события (Post). Аналогична функции [[Ham_Sandwich#SetHamParamFloat|Ham_Sandwich]], за исключением того, что новые параметры задаются строкой. | |
native SetHamParamString(which, const output[]); | native SetHamParamString(which, const output[]); | ||
− | + | {| class="wide" | |
− | + | |- | |
+ | | '''which''' | ||
+ | | Параметр, который нужно изменить | ||
+ | |- | ||
+ | | '''value''' | ||
+ | | Новое значение параметра | ||
+ | |} | ||
=== SetHamParamTraceResult === | === SetHamParamTraceResult === | ||
Строка 196: | Строка 446: | ||
native SetHamParamTraceResult(which, tr_handle); | native SetHamParamTraceResult(which, tr_handle); | ||
− | + | {| class="wide" | |
− | + | |- | |
+ | | '''which''' | ||
+ | | Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this". | ||
+ | |- | ||
+ | | '''value''' | ||
+ | | The value to change it to. | ||
+ | |} | ||
=== IsHamValid === | === IsHamValid === | ||
Строка 203: | Строка 459: | ||
native bool:IsHamValid(Ham:function); | native bool:IsHamValid(Ham:function); | ||
− | + | {| class="wide" | |
− | + | |- | |
+ | | '''function''' | ||
+ | | | ||
+ | |} | ||
+ | |||
+ | Return true if the function is valid, false otherwise. | ||
=== get_pdata_cbase === | === get_pdata_cbase === | ||
Строка 211: | Строка 472: | ||
native get_pdata_cbase(id, offset, linuxdiff=5); | native get_pdata_cbase(id, offset, linuxdiff=5); | ||
− | + | {| class="wide" | |
− | + | |- | |
− | + | | '''id''' | |
− | + | | The entity to examine the private data. | |
+ | |- | ||
+ | | '''offset''' | ||
+ | | The windows offset of the data. | ||
+ | |- | ||
+ | | '''linuxdiff''' | ||
+ | | The linux difference of the data. | ||
+ | |} | ||
+ | |||
+ | Return the index of the corresponding pdata field. -1 for none set. | ||
=== set_pdata_cbase === | === set_pdata_cbase === | ||
Строка 221: | Строка 491: | ||
native set_pdata_cbase(id, offset, value, linuxdiff=5); | native set_pdata_cbase(id, offset, value, linuxdiff=5); | ||
− | + | {| class="wide" | |
− | + | |- | |
− | + | | '''id''' | |
− | + | | The entity to examine the private data. | |
+ | |- | ||
+ | | '''offset''' | ||
+ | | The windows offset of the data. | ||
+ | |- | ||
+ | | '''linuxdiff''' | ||
+ | | The linux difference of the data. | ||
+ | |} | ||
=== get_pdata_cbase_safe === | === get_pdata_cbase_safe === | ||
Строка 231: | Строка 508: | ||
native get_pdata_cbase_safe(id, offset, linuxdiff=5); | native get_pdata_cbase_safe(id, offset, linuxdiff=5); | ||
− | + | {| class="wide" | |
− | + | |- | |
− | + | | '''id''' | |
− | + | | The entity to examine the private data. | |
+ | |- | ||
+ | | '''offset''' | ||
+ | | The windows offset of the data. | ||
+ | |- | ||
+ | | '''linuxdiff''' | ||
+ | | The linux difference of the data. | ||
+ | |} | ||
+ | |||
+ | Return the index of the corresponding pdata field, -1 for null, -2 for invalid. | ||
+ | |||
+ | == Ссылки == | ||
+ | * [http://amxxmodx.ru/hamsandwich/hamsandwichinc/ Примеры Ham Sandwich (рус.)] |
Текущая версия на 12:31, 15 июня 2013
Содержание
- 1 hamsandwich.inc
- 1.1 RegisterHam
- 1.2 RegisterHamFromEntity
- 1.3 DisableHamForward
- 1.4 EnableHamForward
- 1.5 ExecuteHam
- 1.6 ExecuteHamB
- 1.7 GetHamReturnStatus
- 1.8 GetHamReturnInteger
- 1.9 GetHamReturnFloat
- 1.10 GetHamReturnVector
- 1.11 GetHamReturnEntity
- 1.12 GetHamReturnString
- 1.13 GetOrigHamReturnInteger
- 1.14 GetOrigHamReturnFloat
- 1.15 GetOrigHamReturnVector
- 1.16 GetOrigHamReturnEntity
- 1.17 GetOrigHamReturnString
- 1.18 SetHamReturnInteger
- 1.19 SetHamReturnFloat
- 1.20 SetHamReturnVector
- 1.21 SetHamReturnEntity
- 1.22 SetHamReturnString
- 1.23 SetHamParamInteger
- 1.24 SetHamParamFloat
- 1.25 SetHamParamVector
- 1.26 SetHamParamEntity
- 1.27 SetHamParamString
- 1.28 SetHamParamTraceResult
- 1.29 IsHamValid
- 1.30 get_pdata_cbase
- 1.31 set_pdata_cbase
- 1.32 get_pdata_cbase_safe
- 2 Ссылки
hamsandwich.inc
RegisterHam
Отлавливает событие в игровом мире. Список событий очень большой, их описание можно посмотреть в константах Ham Sandwich. Функция возвращает идентификатор созданного форварда, который можно использовать в функциях EnableHamForward/DisableHamForward.
native HamHook:RegisterHam(Ham:function, const EntityClass[], const Callback[], Post=0);
function | Функция (событие). Например убийство. |
EntityClass | Класс объектов с которым происходит событие |
callback | Вызываемая функция |
post | Функция будет вызвана До/Или после события. |
Пример:
Будет вызвана функция player_hurt, перед тем как игрок получит повреждение.
RegisterHam(Ham_TakeDamage, "player", "player_hurt", 0);
RegisterHamFromEntity
Отлавливает событие в игровом мире для определенного энтити-объекта или игрока.
native HamHook:RegisterHamFromEntity(Ham:function, EntityId, const Callback[], Post=0);
function | Событие для отлова |
EntityId | id объекта |
callback | Функция, которая будет вызвана |
post | Функция будет вызвана До/Или после события |
Returns a handle to the forward. Use EnableHamForward/DisableHamForward to toggle the forward on or off.
Пример:
RegisterHam(Ham_TakeDamage, id, "player_hurt", 0);
DisableHamForward
Запускает работу Ham форварда. Противоположность EnableHamForward.
native DisableHamForward(HamHook:fwd);
fwd | ID форварда для остановки. |
EnableHamForward
Запускает работу Ham форварда. Противоположность DisableHamForward.
native EnableHamForward(HamHook:fwd);
fwd | Идентификатор форварда (возвращаемое значение RegisterHam) |
Пример:
new HamHook:g_fwdTakeDamage public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) g_fwdTakeDamage = RegisterHam(Ham_TakeDamage,"player","damager",0) register_clcmd("say /off","f_off") register_clcmd("say /on","f_on") } public f_on(){ EnableHamForward(g_fwdTakeDamage) client_print(0,print_chat,"Forward TakeDamege is enable") } public f_off(){ DisableHamForward(g_fwdTakeDamage) client_print(0,print_chat,"Forward TakeDamege is desable") } public damager(victim, inflicator, attacker, Float:damage){ if(!is_user_connected(attacker)) return; if(victim == attacker || !victim) return; client_print(0,print_chat,"Damage: %.1f health:%d",damage,get_user_health(victim)) }
ExecuteHam
Выполняет виртуальную функцию на энтити-объекте или игроке. Смотрите список параметров.
native ExecuteHam(Ham:function, this, any:...);
function | Функция из списка Ham_ |
this | id объекта к кому применяется функция |
any:... | Дополнительные параметры если есть |
Пример:
Пример респавнит игрока.
public plugin_init() { register_clcmd("say /spawn","spawn"); } public spawn(id){ ExecuteHam( Ham_CS_RoundRespawn, id ); }
ExecuteHamB
Функция аналогична ExecuteHam за исключением того, что результат выполнения можно отловить.
native ExecuteHamB(Ham:function, this, any:...);
function | Функция из списка Ham_* |
this | id объекта |
ani:... | Другие параметры (если есть) |
Пример:
Пример респавнит игрока и выводит сообщение.
public plugin_init() { register_clcmd("say resp","new_life") RegisterHam(Ham_CS_RoundRespawn,"player","player_respawn") } public new_life(id){ ExecuteHamB(Ham_CS_RoundRespawn,id) return PLUGIN_HANDLED } public player_respawn(id){ client_print(0,print_chat,"Ham_CS_RoundRespawn is hooked") }
GetHamReturnStatus
Проверяет статус определенного события. Полезно в случаях когда на сервере установлено два плагина, работающих с одним событием.
native GetHamReturnStatus();
Пример:
Пример отправляет в чат нанесенный урон.
public plugin_init() { RegisterHam(Ham_TakeDamage,"player","damager",0); } public damager(victim, inflicator, attacker, Float:damage){ if(GetHamReturnStatus() != HAM_SUPERCEDE){ client_print(0,print_chat,"Damage: %.1f health:%d",damage,get_user_health(victim)); } }
GetHamReturnInteger
Gets the return value of a hook for hooks that return integers or booleans.
native GetHamReturnInteger(&output);
output | The variable to store the value in. |
GetHamReturnFloat
Gets the return value of a hook for hooks that return float.
native GetHamReturnFloat(&Float:output);
output | The variable to store the value in. |
GetHamReturnVector
Gets the return value of a hook for hooks that return Vectors.
native GetHamReturnVector(Float:output[3]);
output | The variable to store the value in. |
GetHamReturnEntity
Gets the return value of a hook for hooks that return entities.
native GetHamReturnEntity(&output);
output | The variable to store the value in. Will be -1 on null. |
GetHamReturnString
Gets the return value of a hook for hooks that return strings.
native GetHamReturnString(output[], size);
output | The buffer to store the string in. |
size | The string size of the buffer. |
GetOrigHamReturnInteger
Gets the original return value of a hook for hooks that return integers or booleans.
native GetOrigHamReturnInteger(&output);
output | The variable to store the value in. |
GetOrigHamReturnFloat
Gets the original return value of a hook for hooks that return floats.
native GetOrigHamReturnFloat(&Float:output);
output | The variable to store the value in. |
GetOrigHamReturnVector
Gets the original return value of a hook for hooks that return Vectors.
native GetOrigHamReturnVector(Float:output[3]);
output | The variable to store the value in. |
GetOrigHamReturnEntity
Gets the original return value of a hook for hooks that return entities.
native GetOrigHamReturnEntity(&output);
output | The variable to store the value in. -1 on null. |
GetOrigHamReturnString
Gets the original return value of a hook for hooks that return strings.
native GetOrigHamReturnString(output[], size);
output | The buffer to store the string in. |
size | The size of the buffer. |
SetHamReturnInteger
Sets the return value of a hook that returns an integer or boolean. This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE.
native SetHamReturnInteger(value);
value | The value to set the return to. |
SetHamReturnFloat
Sets the return value of a hook that returns a float. This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE.
native SetHamReturnFloat(Float:value);
value | The value to set the return to. |
SetHamReturnVector
Sets the return value of a hook that returns a Vector. This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE.
native SetHamReturnVector(const Float:value[3]);
value | The value to set the return to. |
SetHamReturnEntity
Sets the return value of a hook that returns an entity. Set to -1 for null. This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE.
native SetHamReturnEntity(value);
value | The value to set the return to. |
SetHamReturnString
Sets the return value of a hook that returns a string.This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE.
native SetHamReturnString(const value[]);
value | The value to set the return to. |
SetHamParamInteger
Sets a parameter on the fly of the current hook. This has no effect in post hooks. Use this on parameters that are integers.
native SetHamParamInteger(which, value);
which | Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this". |
value | The value to change it to. |
SetHamParamFloat
Задает параметры отловленного события. Не имеет никакого эффекта, если отлов был после события (Post). Полезна, если требуется увеличить или уменьшить урон, получаемый игроком.
native SetHamParamFloat(which, Float:value);
which | Параметр, который нужно изменить |
value | Новое значение параметра |
Пример: Уменьшаем урон, получаемый игроком в два раза.
4 - параметр урона
public plugin_init() { RegisterHam(Ham_TakeDamage,"player","damager",0); } public damager(victim, inflicator, attacker, Float:damage){ if(!is_user_connected(attacker)){ return; } if(victim == attacker || !victim){ return; } SetHamParamFloat(4, damage * 0.5); }
SetHamParamVector
Задает параметры отловленного события. Не имеет никакого эффекта, если отлов был после события (Post). Аналогична функции Ham_Sandwich, за исключением того, что новые параметры задаются вектором.
native SetHamParamVector(which, const Float:value[3]);
which | Параметр, который нужно изменить |
value | Новое значение параметра |
SetHamParamEntity
Sets a parameter on the fly of the current hook. This has no effect in post hooks. Use this on parameters that are entities.
native SetHamParamEntity(which, value);
which | Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this". |
value | The value to change it to. |
SetHamParamString
Задает параметры отловленного события. Не имеет никакого эффекта, если отлов был после события (Post). Аналогична функции Ham_Sandwich, за исключением того, что новые параметры задаются строкой.
native SetHamParamString(which, const output[]);
which | Параметр, который нужно изменить |
value | Новое значение параметра |
SetHamParamTraceResult
Sets a parameter on the fly of the current hook. This has no effect in post hooks. Use this on parameters that are trace result handles.
native SetHamParamTraceResult(which, tr_handle);
which | Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this". |
value | The value to change it to. |
IsHamValid
Returns whether or not the function for the specified Ham is valid.Things that would make it invalid would be bounds (an older module version may not have all of the functions), and the function not being found in the mod's hamdata.ini file.
native bool:IsHamValid(Ham:function);
function |
Return true if the function is valid, false otherwise.
get_pdata_cbase
This is used to compliment fakemeta's {get,set}_pdata_{int,float,string}.This requires the mod to have the pev and base fields set in hamdata.ini. Note this dereferences memory! Improper use of this will crash the server. This will return an index of the corresponding cbase field in private data. Returns -1 on a null entry.
native get_pdata_cbase(id, offset, linuxdiff=5);
id | The entity to examine the private data. |
offset | The windows offset of the data. |
linuxdiff | The linux difference of the data. |
Return the index of the corresponding pdata field. -1 for none set.
set_pdata_cbase
This is used to compliment fakemeta's {get,set}_pdata_{int,float,string}. This requires the mod to have the pev and base fields set in hamdata.ini. This will set the corresponding cbase field in private data with the index. Pass -1 to null the entry.
native set_pdata_cbase(id, offset, value, linuxdiff=5);
id | The entity to examine the private data. |
offset | The windows offset of the data. |
linuxdiff | The linux difference of the data. |
get_pdata_cbase_safe
This is similar to the get_pdata_cbase, however it does not dereference memory. This is many times slower than get_pdata_cbase, and this should only be used for testing and finding of offsets, not actual release quality plugins. This will return an index of the corresponding cbase field in private data. Returns -1 on a null entry. -2 on an invalid entry.
native get_pdata_cbase_safe(id, offset, linuxdiff=5);
id | The entity to examine the private data. |
offset | The windows offset of the data. |
linuxdiff | The linux difference of the data. |
Return the index of the corresponding pdata field, -1 for null, -2 for invalid.