Skip to content

Commit 5515184

Browse files
authored
API: Added rg_player_relationship native (#304)
1 parent 016a08a commit 5515184

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

reapi/extra/amxmodx/scripting/include/cssdk_const.inc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,3 +1539,15 @@ enum Decal
15391539
DECAL_MOMMABIRTH, // Big momma birth splatter
15401540
DECAL_MOMMASPLAT,
15411541
};
1542+
1543+
/**
1544+
* Player relationship return codes
1545+
*/
1546+
enum
1547+
{
1548+
GR_NOTTEAMMATE = 0,
1549+
GR_TEAMMATE,
1550+
GR_ENEMY,
1551+
GR_ALLY,
1552+
GR_NEUTRAL,
1553+
};

reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,3 +1195,13 @@ native rg_set_observer_mode(const player, const mode);
11951195
* @noreturn
11961196
*/
11971197
native rg_death_notice(const pVictim, const pKiller, const pevInflictor);
1198+
1199+
/*
1200+
* Checks a player relationship with another reference
1201+
*
1202+
* @param player Player index
1203+
* @param target Target index
1204+
*
1205+
* @return Match player relationship, see GR_* constants in cssdk_const.inc
1206+
*/
1207+
native rg_player_relationship(const player, const target);

reapi/src/natives/natives_misc.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3225,6 +3225,30 @@ cell AMX_NATIVE_CALL rg_death_notice(AMX* amx, cell* params)
32253225
return TRUE;
32263226
}
32273227

3228+
/*
3229+
* Checks a player relationship with another reference
3230+
*
3231+
* @param player Player index
3232+
* @param target Target index
3233+
*
3234+
* @return Match player relationship, see GR_* constants in cssdk_const.inc
3235+
*/
3236+
cell AMX_NATIVE_CALL rg_player_relationship(AMX *amx, cell *params)
3237+
{
3238+
enum args_e { arg_count, arg_player, arg_target };
3239+
3240+
CHECK_GAMERULES();
3241+
CHECK_ISPLAYER(arg_player);
3242+
CHECK_ISENTITY(arg_target);
3243+
3244+
CBasePlayer *pPlayer = UTIL_PlayerByIndex(params[arg_player]);
3245+
CHECK_CONNECTED(pPlayer, arg_player);
3246+
3247+
CBaseEntity *pTarget = getPrivate<CBaseEntity>(params[arg_target]);
3248+
3249+
return CSGameRules()->PlayerRelationship(pPlayer, pTarget);
3250+
}
3251+
32283252
AMX_NATIVE_INFO Misc_Natives_RG[] =
32293253
{
32303254
{ "rg_set_animation", rg_set_animation },
@@ -3336,6 +3360,7 @@ AMX_NATIVE_INFO Misc_Natives_RG[] =
33363360
{ "rg_disappear", rg_disappear },
33373361
{ "rg_set_observer_mode", rg_set_observer_mode },
33383362
{ "rg_death_notice", rg_death_notice },
3363+
{ "rg_player_relationship", rg_player_relationship },
33393364

33403365
{ nullptr, nullptr }
33413366
};

0 commit comments

Comments
 (0)