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

Add new native rg_observer_find_next_player #325

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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/reapi_gamedll.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,18 @@ native rg_disappear(const player);
*/
native rg_set_observer_mode(const player, const mode);

/*
* Call origin function CBasePlayer::Observer_FindNextPlayer()
* @note Player must be a valid observer (m_afPhysicsFlags & PFLAG_OBSERVER).
*
* @param player Player index.
* @param bReverse If bReverse is true, finding order will be reversed
* @param name Player name to find.
*
* @noreturn
*/
native rg_observer_find_next_player(const player, const bool:bReverse = false, const name[] = "");

/*
* Emits a death notice (logs, DeathMsg event, win conditions check)
*
Expand Down
1 change: 1 addition & 0 deletions reapi/include/cssdk/dlls/API/CSPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class CCSPlayer: public CCSMonster
virtual void SendItemStatus() = 0;
virtual void ReloadWeapons(CBasePlayerItem *pWeapon = nullptr, bool bForceReload = false, bool bForceRefill = false) = 0;
virtual void Observer_SetMode(int iMode) = 0;
virtual void Observer_FindNextPlayer(bool bReverse, const char *name = nullptr) = 0;
virtual bool SelectSpawnSpot(const char *pEntClassName, CBaseEntity* &pSpot) = 0;
virtual bool SwitchWeapon(CBasePlayerItem *pWeapon) = 0;
virtual void SwitchTeam() = 0;
Expand Down
29 changes: 29 additions & 0 deletions reapi/src/natives/natives_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3242,6 +3242,34 @@ cell AMX_NATIVE_CALL rg_set_observer_mode(AMX* amx, cell* params)
return TRUE;
}

/*
* Call origin function CBasePlayer::Observer_FindNextPlayer()
* @note Player must be a valid observer (m_afPhysicsFlags & PFLAG_OBSERVER).
*
* @param player Player index.
* @param bReverse If bReverse is true, finding order will be reversed
* @param name Player name to find.
*
* @noreturn
*/
cell AMX_NATIVE_CALL rg_observer_find_next_player(AMX* amx, cell* params)
{
enum args_e { arg_count, arg_index, arg_bReverse, arg_name };

CHECK_ISPLAYER(arg_index)

CBasePlayer *pPlayer = UTIL_PlayerByIndex(params[arg_index]);
CHECK_CONNECTED(pPlayer, arg_index);

char nameBuf[MAX_PLAYER_NAME_LENGTH];
const char* name = getAmxString(amx, params[arg_name], nameBuf);
if (strcmp(name, "") == 0)
name = nullptr;

pPlayer->CSPlayer()->Observer_FindNextPlayer(params[arg_bReverse] != 0, name);
return TRUE;
}

/*
* Emits a death notice (logs, DeathMsg event, win conditions check)
*
Expand Down Expand Up @@ -3455,6 +3483,7 @@ AMX_NATIVE_INFO Misc_Natives_RG[] =
{ "rg_switch_best_weapon", rg_switch_best_weapon },
{ "rg_disappear", rg_disappear },
{ "rg_set_observer_mode", rg_set_observer_mode },
{ "rg_observer_find_next_player", rg_observer_find_next_player },
{ "rg_death_notice", rg_death_notice },
{ "rg_player_relationship", rg_player_relationship },

Expand Down
Loading