Fun: Toggle PlayerPreThink forward on demand

This commit is contained in:
Arkshine 2017-03-06 11:29:02 +01:00
parent 5b74e3285a
commit 3fba7ca567
3 changed files with 25 additions and 1 deletions

View File

@ -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);
}

View File

@ -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;

View File

@ -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() */