mirror of
https://github.com/rehlds/reapi.git
synced 2025-01-14 15:48:03 +03:00
Add API to set if player can hear another player (#158)
* Add API to set if player can hear another player
This commit is contained in:
parent
1ea1ff04a1
commit
1ef3c5a753
@ -1,3 +1,3 @@
|
||||
majorVersion=5
|
||||
minorVersion=11
|
||||
minorVersion=12
|
||||
maintenanceVersion=0
|
||||
|
@ -863,3 +863,32 @@ native rg_check_win_conditions();
|
||||
* @noreturn
|
||||
*/
|
||||
native rg_initialize_player_counts(&num_alive_terrorist = 0, &num_alive_ct = 0, &num_dead_terrorist = 0, &num_dead_ct = 0);
|
||||
|
||||
/*
|
||||
* Reset if player can hear another player.
|
||||
*
|
||||
* @param index Player id
|
||||
* @noreturn
|
||||
*/
|
||||
native rg_reset_can_hear_player(const index);
|
||||
|
||||
/*
|
||||
* Set if player can hear another player
|
||||
*
|
||||
* @param listener Listener player id
|
||||
* @param sender Sender player id
|
||||
* @param can_hear Can listener hear sender
|
||||
*
|
||||
* @noreturn
|
||||
*/
|
||||
native rg_set_can_hear_player(const listener, const sender, const bool:can_hear);
|
||||
|
||||
/*
|
||||
* Get if player can hear another player
|
||||
*
|
||||
* @param listener Listener player id
|
||||
* @param sender Sender player id
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
native bool:rg_get_can_hear_player(const listener, const sender);
|
||||
|
@ -673,6 +673,9 @@ typedef struct mapcycle_s
|
||||
class CCStrikeGameMgrHelper: public IVoiceGameMgrHelper {
|
||||
public:
|
||||
virtual bool CanPlayerHearPlayer(CBasePlayer *pListener, CBasePlayer *pSender) = 0;
|
||||
virtual void ResetCanHearPlayer(edict_t* pEdict) = 0;
|
||||
virtual void SetCanHearPlayer(CBasePlayer* pListener, CBasePlayer* pSender, bool bCanHear) = 0;
|
||||
virtual bool GetCanHearPlayer(CBasePlayer* pListener, CBasePlayer* pSender) = 0;
|
||||
};
|
||||
|
||||
extern CGameRules *g_pGameRules;
|
||||
|
@ -38,7 +38,7 @@
|
||||
#include <API/CSInterfaces.h>
|
||||
|
||||
#define REGAMEDLL_API_VERSION_MAJOR 5
|
||||
#define REGAMEDLL_API_VERSION_MINOR 12
|
||||
#define REGAMEDLL_API_VERSION_MINOR 13
|
||||
|
||||
// CBasePlayer::Spawn hook
|
||||
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_Spawn;
|
||||
|
@ -41,6 +41,9 @@ public:
|
||||
// Called each frame to determine which players are allowed to hear each other. This overrides
|
||||
// whatever squelch settings players have.
|
||||
virtual bool CanPlayerHearPlayer(CBasePlayer *pListener, CBasePlayer *pTalker) = 0;
|
||||
virtual void ResetCanHearPlayer(edict_t* pEdict) = 0;
|
||||
virtual void SetCanHearPlayer(CBasePlayer* pListener, CBasePlayer* pSender, bool bCanHear) = 0;
|
||||
virtual bool GetCanHearPlayer(CBasePlayer* pListener, CBasePlayer* pSender) = 0;
|
||||
};
|
||||
|
||||
// CVoiceGameMgr manages which clients can hear which other clients.
|
||||
|
@ -2214,6 +2214,86 @@ cell AMX_NATIVE_CALL rg_initialize_player_counts(AMX *amx, cell *params)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reset if player can hear another player.
|
||||
*
|
||||
* @param index Player id
|
||||
* @noreturn
|
||||
*
|
||||
* native rg_reset_can_hear_player(const index);
|
||||
*/
|
||||
cell AMX_NATIVE_CALL rg_reset_can_hear_player(AMX* amx, cell* params)
|
||||
{
|
||||
enum args_e { arg_count, arg_index };
|
||||
|
||||
CHECK_GAMERULES();
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
CBasePlayer* pPlayer = UTIL_PlayerByIndex(params[arg_index]);
|
||||
CHECK_CONNECTED(pPlayer, arg_index);
|
||||
|
||||
CSGameRules()->m_VoiceGameMgr.m_pHelper->ResetCanHearPlayer(pPlayer->edict());
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set if player can hear another player
|
||||
*
|
||||
* @param listener Listener player id
|
||||
* @param sender Sender player id
|
||||
* @param can_hear Can listener hear sender
|
||||
*
|
||||
* @noreturn
|
||||
*
|
||||
* native rg_set_can_hear_player(const listener, const sender, const bool:can_hear);
|
||||
*/
|
||||
cell AMX_NATIVE_CALL rg_set_can_hear_player(AMX* amx, cell* params)
|
||||
{
|
||||
enum args_e { arg_count, arg_listener, arg_sender, arg_can_hear };
|
||||
|
||||
CHECK_GAMERULES();
|
||||
CHECK_ISPLAYER(arg_listener);
|
||||
CHECK_ISPLAYER(arg_sender);
|
||||
|
||||
CBasePlayer* pListener = UTIL_PlayerByIndex(params[arg_listener]);
|
||||
CHECK_CONNECTED(pListener, arg_listener);
|
||||
|
||||
CBasePlayer* pSender = UTIL_PlayerByIndex(params[arg_sender]);
|
||||
CHECK_CONNECTED(pSender, arg_sender);
|
||||
|
||||
CSGameRules()->m_VoiceGameMgr.m_pHelper->SetCanHearPlayer(pListener, pSender, params[arg_can_hear] != 0);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get if player can hear another player
|
||||
*
|
||||
* @param listener Listener player id
|
||||
* @param sender Sender player id
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* native bool:rg_get_can_hear_player(const listener, const sender);
|
||||
*/
|
||||
cell AMX_NATIVE_CALL rg_get_can_hear_player(AMX* amx, cell* params)
|
||||
{
|
||||
enum args_e { arg_count, arg_listener, arg_sender };
|
||||
|
||||
CHECK_GAMERULES();
|
||||
CHECK_ISPLAYER(arg_listener);
|
||||
CHECK_ISPLAYER(arg_sender);
|
||||
|
||||
CBasePlayer* pListener = UTIL_PlayerByIndex(params[arg_listener]);
|
||||
CHECK_CONNECTED(pListener, arg_listener);
|
||||
|
||||
CBasePlayer* pSender = UTIL_PlayerByIndex(params[arg_sender]);
|
||||
CHECK_CONNECTED(pSender, arg_sender);
|
||||
|
||||
return CSGameRules()->m_VoiceGameMgr.m_pHelper->GetCanHearPlayer(pListener, pSender);
|
||||
}
|
||||
|
||||
AMX_NATIVE_INFO Misc_Natives_RG[] =
|
||||
{
|
||||
{ "rg_set_animation", rg_set_animation },
|
||||
@ -2298,6 +2378,10 @@ AMX_NATIVE_INFO Misc_Natives_RG[] =
|
||||
{ "rg_check_win_conditions", rg_check_win_conditions },
|
||||
{ "rg_initialize_player_counts", rg_initialize_player_counts },
|
||||
|
||||
{ "rg_reset_can_hear_player", rg_reset_can_hear_player },
|
||||
{ "rg_set_can_hear_player", rg_set_can_hear_player },
|
||||
{ "rg_get_can_hear_player", rg_get_can_hear_player },
|
||||
|
||||
{ nullptr, nullptr }
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user