diff --git a/reapi/extra/amxmodx/scripting/include/reapi_engine_const.inc b/reapi/extra/amxmodx/scripting/include/reapi_engine_const.inc index 3835e42..81c4c16 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_engine_const.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_engine_const.inc @@ -161,6 +161,12 @@ enum EngineFunc * Params: (const string[]) */ RH_SV_ClientPrintf, + + /* + * Description: Called when a command is being sent to server. + * Params: (const cmd[], source, id) + */ + RH_ExecuteServerStringCmd, /* * Description: Called before adding an entity to the physents of a player. diff --git a/reapi/src/hook_callback.cpp b/reapi/src/hook_callback.cpp index e785b20..46f662c 100644 --- a/reapi/src/hook_callback.cpp +++ b/reapi/src/hook_callback.cpp @@ -227,6 +227,16 @@ void SV_ClientPrintf(IRehldsHook_SV_ClientPrintf *chain, const char *string) callVoidForward(RH_SV_ClientPrintf, original, string); } +void ExecuteServerStringCmd(IRehldsHook_ExecuteServerStringCmd* chain, const char* cmdName, cmd_source_t cmdSrc, IGameClient* cl) +{ + auto original = [chain](const char* _cmdName, cmd_source_t _cmdSrc, int client) + { + chain->callNext(_cmdName, _cmdSrc, _cmdSrc == src_client ? g_RehldsSvs->GetClient(client) - 1 : 0); + }; + + callVoidForward(RH_ExecuteServerStringCmd, original, cmdName, cmdSrc, cmdSrc == src_client ? cl->GetId() + 1 : 0); +} + /* * ReGameDLL functions */ diff --git a/reapi/src/hook_callback.h b/reapi/src/hook_callback.h index 7e6d93b..6340010 100644 --- a/reapi/src/hook_callback.h +++ b/reapi/src/hook_callback.h @@ -348,6 +348,7 @@ using SV_WriteFullClientUpdate_t = hookdata_t inline size_t getFwdParamType(void(*)(T *)) { return FP_CELL; } @@ -104,6 +105,7 @@ hook_t hooklist_engine[] = { ENG(SV_AddResource), ENG(SV_ClientPrintf), ENG(SV_AllowPhysent), + ENG(ExecuteServerStringCmd), }; diff --git a/reapi/src/hook_list.h b/reapi/src/hook_list.h index 985af8a..9112582 100644 --- a/reapi/src/hook_list.h +++ b/reapi/src/hook_list.h @@ -113,7 +113,8 @@ enum EngineFunc RH_SV_AddResource, RH_SV_ClientPrintf, RH_SV_AllowPhysent, - + RH_ExecuteServerStringCmd, + // [...] };