From 3fba7ca5673ed309334a2ebf92dfba63f1419903 Mon Sep 17 00:00:00 2001 From: Arkshine Date: Mon, 6 Mar 2017 11:29:02 +0100 Subject: [PATCH] Fun: Toggle PlayerPreThink forward on demand --- modules/fun/fun.cpp | 23 +++++++++++++++++++++++ modules/fun/fun.h | 1 + modules/fun/moduleconfig.h | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/modules/fun/fun.cpp b/modules/fun/fun.cpp index d3f13b8d..2bced379 100644 --- a/modules/fun/fun.cpp +++ b/modules/fun/fun.cpp @@ -395,11 +395,26 @@ static cell AMX_NATIVE_CALL set_user_footsteps(AMX *amx, cell *params) { pPlayer->v.flTimeStepSound = 999; Players[index].SetSilentFootsteps(true); + + g_pFunctionTable->pfnPlayerPreThink = PlayerPreThink; } else { pPlayer->v.flTimeStepSound = STANDARDTIMESTEPSOUND; Players[index].SetSilentFootsteps(false); + + if (g_pFunctionTable->pfnPlayerPreThink) + { + for (auto i = 1; i <= gpGlobals->maxClients; ++i) + { + if (Players[i].HasSilentFootsteps()) + { + return 1; + } + } + + g_pFunctionTable->pfnPlayerPreThink = nullptr; + } } return 1; @@ -527,5 +542,13 @@ void OnPluginsLoaded() } TypeConversion.init(); + + g_pFunctionTable->pfnPlayerPreThink = nullptr; } +void ServerDeactivate() +{ + g_pFunctionTable->pfnPlayerPreThink = nullptr; + + RETURN_META(MRES_IGNORED); +} diff --git a/modules/fun/fun.h b/modules/fun/fun.h index 4836773f..70cb47f9 100644 --- a/modules/fun/fun.h +++ b/modules/fun/fun.h @@ -31,6 +31,7 @@ #define HITGROUP_RIGHTLEG 7 // 128 #define HITGROUP_MAX 8 +extern DLL_FUNCTIONS *g_pFunctionTable; static const auto kHitGroupsBits = (1 << HITGROUP_MAX) - 1; static const auto kMaxClients = 32u; diff --git a/modules/fun/moduleconfig.h b/modules/fun/moduleconfig.h index 06c8b963..112c9fae 100644 --- a/modules/fun/moduleconfig.h +++ b/modules/fun/moduleconfig.h @@ -119,7 +119,7 @@ // #define FN_ClientCommand ClientCommand /* pfnClientCommand() (wd) Player has sent a command (typed or from a bind) */ // #define FN_ClientUserInfoChanged ClientUserInfoChanged /* pfnClientUserInfoChanged() (wd) Client has updated their setinfo structure */ // #define FN_ServerActivate ServerActivate /* pfnServerActivate() (wd) Server is starting a new map */ -// #define FN_ServerDeactivate ServerDeactivate /* pfnServerDeactivate() (wd) Server is leaving the map (shutdown or changelevel); SDK2 */ +#define FN_ServerDeactivate ServerDeactivate /* pfnServerDeactivate() (wd) Server is leaving the map (shutdown or changelevel); SDK2 */ #define FN_PlayerPreThink PlayerPreThink /* pfnPlayerPreThink() */ // #define FN_PlayerPostThink PlayerPostThink /* pfnPlayerPostThink() */ // #define FN_StartFrame StartFrame /* pfnStartFrame() */