From b82588f081a5e41248b560da53ee35141fdd7313 Mon Sep 17 00:00:00 2001 From: Arkshine Date: Sat, 4 Jul 2015 16:21:48 +0200 Subject: [PATCH] Cstrike: cs_set_user_deaths - Add a param to choose whether scoreboard should be updated --- modules/cstrike/cstrike/CstrikeNatives.cpp | 26 +++++++++++++++------- plugins/include/cstrike.inc | 3 ++- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/modules/cstrike/cstrike/CstrikeNatives.cpp b/modules/cstrike/cstrike/CstrikeNatives.cpp index e7ba307e..05d2ca5a 100644 --- a/modules/cstrike/cstrike/CstrikeNatives.cpp +++ b/modules/cstrike/cstrike/CstrikeNatives.cpp @@ -80,7 +80,7 @@ static cell AMX_NATIVE_CALL cs_get_user_deaths(AMX *amx, cell *params) return get_pdata(pPlayer, m_iDeaths); } -// native cs_set_user_deaths(index, newdeaths); +// native cs_set_user_deaths(index, newdeaths, bool:scoreboard = true); static cell AMX_NATIVE_CALL cs_set_user_deaths(AMX *amx, cell *params) { GET_OFFSET("CBasePlayer", m_iDeaths); @@ -94,13 +94,23 @@ static cell AMX_NATIVE_CALL cs_set_user_deaths(AMX *amx, cell *params) set_pdata(pPlayer, m_iDeaths, deaths); - MESSAGE_BEGIN(MSG_ALL, MessageIdScoreInfo); - WRITE_BYTE(index); - WRITE_SHORT(static_cast(pPlayer->v.frags)); - WRITE_SHORT(deaths); - WRITE_SHORT(0); - WRITE_SHORT(get_pdata(pPlayer, m_iTeam)); - MESSAGE_END(); + bool updateScoreboard = true; + + if (*params / sizeof(cell) >= 3) + { + updateScoreboard = params[3] != 0; + } + + if (updateScoreboard) + { + MESSAGE_BEGIN(MSG_ALL, MessageIdScoreInfo); + WRITE_BYTE(index); + WRITE_SHORT(static_cast(pPlayer->v.frags)); + WRITE_SHORT(deaths); + WRITE_SHORT(0); + WRITE_SHORT(get_pdata(pPlayer, m_iTeam)); + MESSAGE_END(); + } *static_cast(MF_PlayerPropAddr(index, Player_Deaths)) = deaths; diff --git a/plugins/include/cstrike.inc b/plugins/include/cstrike.inc index f9642f03..3171ee75 100755 --- a/plugins/include/cstrike.inc +++ b/plugins/include/cstrike.inc @@ -152,13 +152,14 @@ native cs_get_user_deaths(index); * * @param index Client index * @param newdeaths New value to set + * @param scoreboard If true the scoreboard will be updated to reflect the new value. * * @noreturn * @error If the client index is not within the range of 1 to * MaxClients, or the client is not connected, an error * will be thrown. */ -native cs_set_user_deaths(index, newdeaths); +native cs_set_user_deaths(index, newdeaths, bool:scoreboard = true); /** * Returns index of the entity that a hostage is following.