From c27bfcd7fe12fe6cc7831279627e1de2dab75713 Mon Sep 17 00:00:00 2001 From: Artem Golubikhin Date: Sat, 18 Feb 2017 21:53:58 +0300 Subject: [PATCH] Fix client_death forward called on kill command if sent by a spectator (#404) --- modules/cstrike/csx/meta_api.cpp | 26 ++++++++++++++++++-------- modules/cstrike/csx/moduleconfig.h | 2 +- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/modules/cstrike/csx/meta_api.cpp b/modules/cstrike/csx/meta_api.cpp index 81840be3..19f0f495 100644 --- a/modules/cstrike/csx/meta_api.cpp +++ b/modules/cstrike/csx/meta_api.cpp @@ -125,17 +125,27 @@ const char* get_localinfo( const char* name , const char* def = 0 ) return b; } +static bool ClientKill_wasAlive; + +void ClientKill(edict_t *pEntity) +{ + CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity); + ClientKill_wasAlive = pPlayer->IsAlive(); + + RETURN_META(MRES_IGNORED); +} + void ClientKill_Post(edict_t *pEntity) { CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity); - if ( pPlayer->IsAlive()) - RETURN_META(MRES_IGNORED); - - MF_ExecuteForward( iFDamage,static_cast(pPlayer->index), static_cast(pPlayer->index) , - static_cast(0), static_cast(0), static_cast(0), static_cast(0) ); // he would - pPlayer->saveKill(pPlayer,0,0,0); - MF_ExecuteForward( iFDeath,static_cast(pPlayer->index), static_cast(pPlayer->index), - static_cast(0), static_cast(0), static_cast(0) ); + if (ClientKill_wasAlive && !pPlayer->IsAlive()) + { + MF_ExecuteForward(iFDamage, static_cast(pPlayer->index), static_cast(pPlayer->index), + static_cast(0), static_cast(0), static_cast(0), static_cast(0)); // he would + pPlayer->saveKill(pPlayer, 0, 0, 0); + MF_ExecuteForward(iFDeath, static_cast(pPlayer->index), static_cast(pPlayer->index), + static_cast(0), static_cast(0), static_cast(0)); + } RETURN_META(MRES_IGNORED); } diff --git a/modules/cstrike/csx/moduleconfig.h b/modules/cstrike/csx/moduleconfig.h index d8aa5733..6f0ad412 100644 --- a/modules/cstrike/csx/moduleconfig.h +++ b/modules/cstrike/csx/moduleconfig.h @@ -119,7 +119,7 @@ // #define FN_ResetGlobalState ResetGlobalState /* pfnResetGlobalState() */ // #define FN_ClientConnect ClientConnect /* pfnClientConnect() (wd) Client has connected */ #define FN_ClientDisconnect ClientDisconnect /* pfnClientDisconnect() (wd) Player has left the game */ -// #define FN_ClientKill ClientKill /* pfnClientKill() (wd) Player has typed "kill" */ +#define FN_ClientKill ClientKill /* pfnClientKill() (wd) Player has typed "kill" */ // #define FN_ClientPutInServer ClientPutInServer /* pfnClientPutInServer() (wd) Client is entering the game */ // #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 */