Skip to content

Commit

Permalink
implement rg_send_death_message native
Browse files Browse the repository at this point in the history
  • Loading branch information
FEDERICOMB96 committed Feb 8, 2024
1 parent 15ba121 commit 4063428
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
18 changes: 17 additions & 1 deletion reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1204,4 +1204,20 @@ native rg_death_notice(const pVictim, const pKiller, const pevInflictor);
*
* @return Match player relationship, see GR_* constants in cssdk_const.inc
*/
native rg_player_relationship(const player, const target);
native rg_player_relationship(const player, const target);

/*
* Sends death messages to all players, including info about the killer, victim, weapon used,
* extra death flags, death position, assistant, and kill rarity
*
* @param pKiller Killer index (if any).
* @param pVictim Victim index.
* @param pAssister Assisting player index (if any).
* @param pevInflictor Inflictor entity. 0 = world
* @param killerWeaponName The name of the weapon used by the killer.
* @param iDeathMessageFlags Flags indicating extra death message info, see DeathMessageFlags enum in cssdk_const.inc
* @param iRarityOfKill An bitsums representing the rarity classification of the kill, see KillRarity enum in cssdk_const.inc
*
* @noreturn
*/
native rg_send_death_message(const pKiller, const pVictim, const pAssister, const pevInflictor, const killerWeaponName[], const DeathMessageFlags:iDeathMessageFlags, const KillRarity:iRarityOfKill);
2 changes: 2 additions & 0 deletions reapi/include/cssdk/dlls/gamerules.h
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,8 @@ class CHalfLifeMultiplay: public CGameRules
virtual bool HasRoundTimeExpired() = 0;
virtual bool IsBombPlanted() = 0;

virtual void SendDeathMessage(CBaseEntity *pKiller, CBasePlayer *pVictim, CBasePlayer *pAssister, entvars_t *pevInflictor, const char *killerWeaponName, int iDeathMessageFlags, int iRarityOfKill) = 0;

public:
bool ShouldSkipShowMenu() const { return m_bSkipShowMenu; }
void MarkShowMenuSkipped() { m_bSkipShowMenu = false; }
Expand Down
54 changes: 54 additions & 0 deletions reapi/src/natives/natives_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3293,6 +3293,58 @@ cell AMX_NATIVE_CALL rg_player_relationship(AMX *amx, cell *params)
return CSGameRules()->PlayerRelationship(pPlayer, pTarget);
}

/*
* Sends death messages to all players, including info about the killer, victim, weapon used,
* extra death flags, death position, assistant, and kill rarity
*
* @param pKiller The entity who performed the kill (Note: The killer may be a non-player)
* @param pVictim The player who was killed
* @param pAssister The assisting player (if any)
* @param pevInflictor Inflictor entity. 0 = world
* @param killerWeaponName The name of the weapon used by the killer
* @param iDeathMessageFlags Flags indicating extra death message info
* @param iRarityOfKill An bitsums representing the rarity classification of the kill
*
* @noreturn
*/
cell AMX_NATIVE_CALL rg_send_death_message(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_killer, arg_victim, arg_assister, arg_inflictor, arg_weaponname, arg_deathmsgflags, arg_rarityofkill };

CHECK_GAMERULES();

CHECK_ISPLAYER(arg_victim);
CBasePlayer *pVictim = UTIL_PlayerByIndex(params[arg_victim]);
CHECK_CONNECTED(pVictim, arg_victim);

CBasePlayer *pKiller = nullptr;
CBasePlayer *pAssister = nullptr;

// Check if the killer is a player
if (params[arg_killer])
{
CHECK_ISPLAYER(arg_killer);
pKiller = UTIL_PlayerByIndex(params[arg_killer]);
CHECK_CONNECTED(pKiller, arg_killer);
}

// Check if the assister is a player
if (params[arg_assister])
{
CHECK_ISPLAYER(arg_assister);
pAssister = UTIL_PlayerByIndex(params[arg_assister]);
CHECK_CONNECTED(pAssister, arg_assister);
}

CAmxArgs args(amx, params);

char weaponStr[32];
const char *weaponName = getAmxString(amx, params[arg_weaponname], weaponStr);

CSGameRules()->SendDeathMessage(pKiller, pVictim, pAssister, args[arg_inflictor], weaponName, args[arg_deathmsgflags], args[arg_rarityofkill]);
return TRUE;
}

AMX_NATIVE_INFO Misc_Natives_RG[] =
{
{ "rg_set_animation", rg_set_animation },
Expand Down Expand Up @@ -3406,6 +3458,8 @@ AMX_NATIVE_INFO Misc_Natives_RG[] =
{ "rg_death_notice", rg_death_notice },
{ "rg_player_relationship", rg_player_relationship },

{ "rg_send_death_message", rg_send_death_message },

{ nullptr, nullptr }
};

Expand Down

0 comments on commit 4063428

Please sign in to comment.