HookEntity

Last Updated2021-11-17
Created At2021-11-17

Hook an entity. Entity hooks are auto-removed when the entity is destroyed. If you need to read the return value of the function, choose a post hook.

native int HookEntity(HookMode mode, int entity, DHookCallback callback, DHookRemovalCB removalcb = INVALID_FUNCTION)

Parameters

The desired hook mode - pre or post. A pre hook calls your callback BEFORE the original function is called. You can access the parameters, set the return value, and skip the original function. A post hook calls your callback AFTER the original function executed. You can access the parameters and get/set the return value.
int entity
Entity index to hook on.
DHookCallback callback
Callback function.
DHookRemovalCB removalcb
Optional callback for when the hook is removed.

Return Value

int A hookid on success, INVALID_HOOK_ID otherwise.

Error

Invalid setup handle, invalid address, invalid hook type or invalid callback.