From 55151847af3d61d9a53dc8278bf4bfb3de059ce3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=82=AF=E5=AE=9A=E9=BE=99?= <52111952+overl4y@users.noreply.github.com> Date: Wed, 31 Jan 2024 08:56:38 -0400 Subject: [PATCH] API: Added rg_player_relationship native (#304) --- .../amxmodx/scripting/include/cssdk_const.inc | 12 +++++++++ .../scripting/include/reapi_gamedll.inc | 10 ++++++++ reapi/src/natives/natives_misc.cpp | 25 +++++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/reapi/extra/amxmodx/scripting/include/cssdk_const.inc b/reapi/extra/amxmodx/scripting/include/cssdk_const.inc index a3bfc5e..0f91158 100644 --- a/reapi/extra/amxmodx/scripting/include/cssdk_const.inc +++ b/reapi/extra/amxmodx/scripting/include/cssdk_const.inc @@ -1539,3 +1539,15 @@ enum Decal DECAL_MOMMABIRTH, // Big momma birth splatter DECAL_MOMMASPLAT, }; + +/** +* Player relationship return codes +*/ +enum +{ + GR_NOTTEAMMATE = 0, + GR_TEAMMATE, + GR_ENEMY, + GR_ALLY, + GR_NEUTRAL, +}; \ No newline at end of file diff --git a/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc b/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc index 060f36f..454ff8c 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc @@ -1195,3 +1195,13 @@ native rg_set_observer_mode(const player, const mode); * @noreturn */ native rg_death_notice(const pVictim, const pKiller, const pevInflictor); + +/* +* Checks a player relationship with another reference +* +* @param player Player index +* @param target Target index +* +* @return Match player relationship, see GR_* constants in cssdk_const.inc +*/ +native rg_player_relationship(const player, const target); \ No newline at end of file diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp index ccd9d0b..6d4c5a5 100644 --- a/reapi/src/natives/natives_misc.cpp +++ b/reapi/src/natives/natives_misc.cpp @@ -3225,6 +3225,30 @@ cell AMX_NATIVE_CALL rg_death_notice(AMX* amx, cell* params) return TRUE; } +/* +* Checks a player relationship with another reference +* +* @param player Player index +* @param target Target index +* +* @return Match player relationship, see GR_* constants in cssdk_const.inc +*/ +cell AMX_NATIVE_CALL rg_player_relationship(AMX *amx, cell *params) +{ + enum args_e { arg_count, arg_player, arg_target }; + + CHECK_GAMERULES(); + CHECK_ISPLAYER(arg_player); + CHECK_ISENTITY(arg_target); + + CBasePlayer *pPlayer = UTIL_PlayerByIndex(params[arg_player]); + CHECK_CONNECTED(pPlayer, arg_player); + + CBaseEntity *pTarget = getPrivate(params[arg_target]); + + return CSGameRules()->PlayerRelationship(pPlayer, pTarget); +} + AMX_NATIVE_INFO Misc_Natives_RG[] = { { "rg_set_animation", rg_set_animation }, @@ -3336,6 +3360,7 @@ AMX_NATIVE_INFO Misc_Natives_RG[] = { "rg_disappear", rg_disappear }, { "rg_set_observer_mode", rg_set_observer_mode }, { "rg_death_notice", rg_death_notice }, + { "rg_player_relationship", rg_player_relationship }, { nullptr, nullptr } };