Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: Added rg_player_relationship native #304

Merged
merged 2 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions reapi/extra/amxmodx/scripting/include/cssdk_const.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
10 changes: 10 additions & 0 deletions reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
25 changes: 25 additions & 0 deletions reapi/src/natives/natives_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CBaseEntity>(params[arg_target]);

return CSGameRules()->PlayerRelationship(pPlayer, pTarget);
}

AMX_NATIVE_INFO Misc_Natives_RG[] =
{
{ "rg_set_animation", rg_set_animation },
Expand Down Expand Up @@ -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 }
};
Expand Down
Loading