diff --git a/extensions/sdktools/hooks.cpp b/extensions/sdktools/hooks.cpp index 9d5dcebc..852bbf90 100644 --- a/extensions/sdktools/hooks.cpp +++ b/extensions/sdktools/hooks.cpp @@ -32,6 +32,8 @@ #include "hooks.h" #include "extension.h" +#define FEATURECAP_PLAYERRUNCMD_11PARAMS "SDKTools PlayerRunCmd 11Params" + CHookManager g_Hooks; static bool PRCH_enabled = false; static bool PRCH_used = false; @@ -53,8 +55,20 @@ void CHookManager::Initialize() } plsys->AddPluginsListener(this); + sharesys->AddCapabilityProvider(myself, this, FEATURECAP_PLAYERRUNCMD_11PARAMS); - m_usercmdsFwd = forwards->CreateForward("OnPlayerRunCmd", ET_Event, 6, NULL, Param_Cell, Param_CellByRef, Param_CellByRef, Param_Array, Param_Array, Param_CellByRef); + m_usercmdsFwd = forwards->CreateForward("OnPlayerRunCmd", ET_Event, 11, NULL, + Param_Cell, // client + Param_CellByRef, // buttons + Param_CellByRef, // impulse + Param_Array, // Float:vel[3] + Param_Array, // Float:angles[3] + Param_CellByRef, // weapon + Param_CellByRef, // subtype + Param_CellByRef, // cmdnum + Param_CellByRef, // tickcount + Param_CellByRef, // seed + Param_Array); // mouse[2] } void CHookManager::Shutdown() @@ -62,6 +76,7 @@ void CHookManager::Shutdown() forwards->ReleaseForward(m_usercmdsFwd); plsys->RemovePluginsListener(this); + sharesys->DropCapabilityProvider(myself, this, FEATURECAP_PLAYERRUNCMD_11PARAMS); } void CHookManager::OnClientPutInServer(int client) @@ -151,6 +166,7 @@ void CHookManager::PlayerRunCmd(CUserCmd *ucmd, IMoveHelper *moveHelper) cell_t impulse = ucmd->impulse; cell_t vel[3] = {sp_ftoc(ucmd->forwardmove), sp_ftoc(ucmd->sidemove), sp_ftoc(ucmd->upmove)}; cell_t angles[3] = {sp_ftoc(ucmd->viewangles.x), sp_ftoc(ucmd->viewangles.y), sp_ftoc(ucmd->viewangles.z)}; + cell_t mouse[2] = {ucmd->mousedx, ucmd->mousedy}; m_usercmdsFwd->PushCell(client); m_usercmdsFwd->PushCellByRef(&ucmd->buttons); @@ -158,6 +174,11 @@ void CHookManager::PlayerRunCmd(CUserCmd *ucmd, IMoveHelper *moveHelper) m_usercmdsFwd->PushArray(vel, 3, SM_PARAM_COPYBACK); m_usercmdsFwd->PushArray(angles, 3, SM_PARAM_COPYBACK); m_usercmdsFwd->PushCellByRef(&ucmd->weaponselect); + m_usercmdsFwd->PushCellByRef(&ucmd->weaponsubtype); + m_usercmdsFwd->PushCellByRef(&ucmd->command_number); + m_usercmdsFwd->PushCellByRef(&ucmd->tick_count); + m_usercmdsFwd->PushCellByRef(&ucmd->random_seed); + m_usercmdsFwd->PushArray(mouse, 2, SM_PARAM_COPYBACK); m_usercmdsFwd->Execute(&result); ucmd->impulse = impulse; @@ -167,6 +188,8 @@ void CHookManager::PlayerRunCmd(CUserCmd *ucmd, IMoveHelper *moveHelper) ucmd->viewangles.x = sp_ctof(angles[0]); ucmd->viewangles.y = sp_ctof(angles[1]); ucmd->viewangles.z = sp_ctof(angles[2]); + ucmd->mousedx = mouse[0]; + ucmd->mousedy = mouse[1]; if (result == Pl_Handled) @@ -222,3 +245,8 @@ void CHookManager::OnPluginUnloaded(IPlugin *plugin) PRCH_used = false; } + +FeatureStatus CHookManager::GetFeatureStatus(FeatureType type, const char *name) +{ + return FeatureStatus_Available; +} diff --git a/extensions/sdktools/hooks.h b/extensions/sdktools/hooks.h index c57dded8..a7ffa759 100644 --- a/extensions/sdktools/hooks.h +++ b/extensions/sdktools/hooks.h @@ -40,7 +40,7 @@ #include "usercmd.h" #include "extension.h" -class CHookManager : IPluginsListener +class CHookManager : IPluginsListener, IFeatureProvider { public: CHookManager(); @@ -52,6 +52,8 @@ public: public: //IPluginsListener void OnPluginLoaded(IPlugin *plugin); void OnPluginUnloaded(IPlugin *plugin); +public: //IFeatureProvider + virtual FeatureStatus GetFeatureStatus(FeatureType type, const char *name); private: IForward *m_usercmdsFwd; diff --git a/plugins/include/sdktools_hooks.inc b/plugins/include/sdktools_hooks.inc index 67762b72..26abcbff 100644 --- a/plugins/include/sdktools_hooks.inc +++ b/plugins/include/sdktools_hooks.inc @@ -35,6 +35,8 @@ #endif #define _sdktools_hooks_included +#define FEATURECAP_PLAYERRUNCMD_11PARAMS "SDKTools PlayerRunCmd 11Params" + /** * @brief Called when a clients movement buttons are being processed * @@ -44,6 +46,14 @@ * @param vel Players desired velocity. * @param angles Players desired view angles. * @param weapon Entity index of the new weapon if player switches weapon, 0 otherwise. + * @param subtype Weapon subtype when selected from a menu. + * @param cmdnum Command number. Increments from the first command sent. + * @param tickcount Tick count. A client's prediction based on the server's GetGameTickCount value. + * @param seed Random seed. Used to determine weapon recoil, spread, and other predicted elements. + * @param mouse Mouse direction (x, y). * @return Plugin_Handled to block the commands from being processed, Plugin_Continue otherwise. + * + * @note To see if all 11 params are avaliable, use FeatureType_Capability and + * FEATURECAP_PLAYERRUNCMD_11PARAMS. */ -forward Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon); \ No newline at end of file +forward Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon, &subtype, &cmdnum, &tickcount, &seed, mouse[2]); \ No newline at end of file