Fix client_death forward called on kill command if sent by a spectator (#404)

This commit is contained in:
Artem Golubikhin 2017-02-18 21:53:58 +03:00 committed by Vincent Herbet
parent 38b8dc338d
commit c27bfcd7fe
2 changed files with 19 additions and 9 deletions

View File

@ -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);
if (ClientKill_wasAlive && !pPlayer->IsAlive())
{
MF_ExecuteForward(iFDamage, static_cast<cell>(pPlayer->index), static_cast<cell>(pPlayer->index),
static_cast<cell>(0), static_cast<cell>(0), static_cast<cell>(0), static_cast<cell>(0)); // he would
pPlayer->saveKill(pPlayer, 0, 0, 0);
MF_ExecuteForward(iFDeath, static_cast<cell>(pPlayer->index), static_cast<cell>(pPlayer->index),
static_cast<cell>(0), static_cast<cell>(0), static_cast<cell>(0));
}
RETURN_META(MRES_IGNORED);
}

View File

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