From 9e16f2769ab0d820fc0deb85a77fc55f67183601 Mon Sep 17 00:00:00 2001 From: fl0werD Date: Mon, 30 Nov 2020 12:37:03 +0400 Subject: [PATCH] Add API check if is player can respawn (#174) --- gradle.properties | 2 +- .../scripting/include/reapi_gamedll.inc | 11 +++++++- reapi/src/natives/natives_misc.cpp | 25 ++++++++++++++++++- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index 66a24d0..107964b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ majorVersion=5 -minorVersion=16 +minorVersion=17 maintenanceVersion=0 diff --git a/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc b/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc index 787f1df..ca48e57 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc @@ -741,10 +741,19 @@ native TeamName:rg_get_join_team_priority(); * @param index Client index * @param attacker Attacker index * -* @return true if he can take damage, false otherwise +* @return true if player can take damage, false otherwise */ native bool:rg_is_player_can_takedamage(const index, const attacker); +/* +* Checks whether the player can respawn. +* +* @param index Client index +* +* @return true if player can respawn, false otherwise +*/ +native bool:rg_is_player_can_respawn(const index); + /* * Gets WeaponIdType from weaponbox * diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp index 7c7cde4..3ce9c96 100644 --- a/reapi/src/natives/natives_misc.cpp +++ b/reapi/src/natives/natives_misc.cpp @@ -1775,7 +1775,7 @@ cell AMX_NATIVE_CALL rg_get_join_team_priority(AMX *amx, cell *params) * @param index Client index * @param attacker Attacker index * -* @return true if he can take damage, false otherwise +* @return true if player can take damage, false otherwise * * native bool:rg_is_player_can_takedamage(const index, const attacker); */ @@ -1798,6 +1798,28 @@ cell AMX_NATIVE_CALL rg_is_player_can_takedamage(AMX *amx, cell *params) return CSGameRules()->FPlayerCanTakeDamage(pPlayer, pAttacker); } +/* +* Checks whether the player can respawn. +* +* @param index Client index +* +* @return true if player can respawn, false otherwise +* +* native bool:rg_is_player_can_respawn(const index); +*/ +cell AMX_NATIVE_CALL rg_is_player_can_respawn(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); + + return CSGameRules()->FPlayerCanRespawn(pPlayer); +} + /* * Gets WeaponIdType from weaponbox * @@ -2361,6 +2383,7 @@ AMX_NATIVE_INFO Misc_Natives_RG[] = { "rg_switch_weapon", rg_switch_weapon }, { "rg_get_join_team_priority", rg_get_join_team_priority }, { "rg_is_player_can_takedamage", rg_is_player_can_takedamage }, + { "rg_is_player_can_respawn", rg_is_player_can_respawn }, { "rg_get_weaponbox_id", rg_get_weaponbox_id }, { "rg_round_respawn", rg_round_respawn }, { "rg_reset_maxspeed", rg_reset_maxspeed },