Ham Sandwich

Материал из HLDM Wiki
Перейти к навигации Перейти к поиску

hamsandwich.inc

RegisterHam

Hooks the virtual table for the specified entity class. Look at the Ham enum for parameter lists.

native HamHook:RegisterHam(Ham:function, const EntityClass[], const Callback[], Post=0);

Пример:

RegisterHam(Ham_TakeDamage, "player", "player_hurt"); 
  • @param function The function to hook.
  • @param EntityClass 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

RegisterHamFromEntity

Hooks the virtual table for the specified entity's class.

native HamHook:RegisterHamFromEntity(Ham:function, EntityId, const Callback[], Post=0);
  • @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.

Пример:

RegisterHam(Ham_TakeDamage, id, "player_hurt");

DisableHamForward

Stops a ham forward from triggering. Use the return value from RegisterHam as the parameter here!

native DisableHamForward(HamHook:fwd);
  • @param fwd The forward to stop.

EnableHamForward

Starts a ham forward back up. Use the return value from RegisterHam as the parameter here!

native EnableHamForward(HamHook:fwd);
  • @param fwd The forward to re-enable.

ExecuteHam

Executes the virtual function on the entity. Look at the Ham enum for parameter lists.

native ExecuteHam(Ham:function, this, any:...);
  • @param function The function to call.
  • @param id The id of the entity to execute it on.

ExecuteHamB

Executes the virtual function on the entity, this will trigger all hooks on that function. Be very careful about recursion! Look at the Ham enum for parameter lists.

native ExecuteHamB(Ham:function, this, any:...);
  • @param function The function to call.
  • @param id The id of the entity to execute it on.

GetHamReturnStatus

Gets the return status of the current hook. This is useful to determine what return natives to use.

native GetHamReturnStatus();
  • @return The current status of the hook (such as HAM_SUPERCEDE).

GetHamReturnInteger

Gets the return value of a hook for hooks that return integers or booleans.

native GetHamReturnInteger(&output);
  • @param 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);
  • @param 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]);
  • @param output The variable to store the value in.

GetHamReturnEntity

Gets the return value of a hook for hooks that return entities.

native GetHamReturnEntity(&output);
  • @param 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);
  • @param output The buffer to store the string in.
  • @param 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);
  • @param 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);
  • @param 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]);
  • @param 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);
  • @param 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);
  • @param output The buffer to store the string in.
  • @param 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);
  • @param 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);
  • @param 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]);
  • @param 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);
  • @param 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[]);
  • @param 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);
* @param which				Which parameter to change.  Starts at 1, and works up from the left to right.  1 is always "this".
* @param value				The value to change it to.

SetHamParamFloat

Sets a parameter on the fly of the current hook. This has no effect in post hooks. Use this on parameters that are floats.

native SetHamParamFloat(which, Float:value);
  • @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
  • @param value The value to change it to.

SetHamParamVector

Sets a parameter on the fly of the current hook. This has no effect in post hooks. Use this on parameters that are Vectors.

native SetHamParamVector(which, const Float:value[3]);
  • @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
  • @param value The value to change it to.

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);
  • @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
  • @param value The value to change it to.

SetHamParamString

Sets a parameter on the fly of the current hook. This has no effect in post hooks.Use this on parameters that are strings.

native SetHamParamString(which, const output[]);
  • @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
  • @param value The value to change it to.

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);
* @param which				Which parameter to change.  Starts at 1, and works up from the left to right.  1 is always "this".
* @param 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);
  • @param function The function to look up.
  • @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);
  • @param id The entity to examine the private data.
  • @param offset The windows offset of the data.
  • @param 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);
  • @param id The entity to examine the private data.
  • @param offset The windows offset of the data.
  • @param value The index to store, -1 for invalid
  • @param 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);
  • @param id Entry to examine the private data.
  • @param offset The windows offset of the data.
  • @param linuxdiff The linux difference of the data.
  • @return The index of the corresponding pdata field, -1 for null, -2 for invalid.