Skip to content

Commit

Permalink
Spawn protection
Browse files Browse the repository at this point in the history
  • Loading branch information
aleeperezz16 committed Mar 30, 2024
1 parent a736d6e commit 5ac34ac
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
21 changes: 20 additions & 1 deletion reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1213,4 +1213,23 @@ native rg_death_notice(const pVictim, const pKiller, const pevInflictor);
*
* @return Match player relationship, see GR_* constants in cssdk_const.inc
*/
native rg_player_relationship(const player, const target);
native rg_player_relationship(const player, const target);

/*
* Removes spawn protection from a player
*
* @param player Player index
*
* @noreturn
*/
native rg_remove_spawn_protection(const player);

/*
* Sets spawn protection for a player with given time
*
* @param player Player index
* @param time Protection time
*
* @noreturn
*/
native rg_set_spawn_protection(const player, const Float:time);
42 changes: 42 additions & 0 deletions reapi/src/natives/natives_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3316,6 +3316,46 @@ cell AMX_NATIVE_CALL rg_player_relationship(AMX *amx, cell *params)
return CSGameRules()->PlayerRelationship(pPlayer, pTarget);
}


/*
* Removes spawn protection from a player
*
* @param player Player index
*
* @noreturn
*/
cell AMX_NATIVE_CALL rg_remove_spawn_protection(AMX* amx, cell* params) {
enum args_e { arg_count, arg_player };

CHECK_ISPLAYER(arg_player);

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

pPlayer->CSPlayer()->RemoveSpawnProtection();
return TRUE;
}

/*
* Sets spawn protection for a player with given time
*
* @param player Player index
* @param time Protection time
*
* @noreturn
*/
cell AMX_NATIVE_CALL rg_set_spawn_protection(AMX* amx, cell* params) {
enum args_e { arg_count, arg_player, arg_time };

CHECK_ISPLAYER(arg_player);

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

pPlayer->CSPlayer()->SetSpawnProtection(params[arg_time]);
return TRUE;
}

AMX_NATIVE_INFO Misc_Natives_RG[] =
{
{ "rg_set_animation", rg_set_animation },
Expand Down Expand Up @@ -3429,6 +3469,8 @@ AMX_NATIVE_INFO Misc_Natives_RG[] =
{ "rg_set_observer_mode", rg_set_observer_mode },
{ "rg_death_notice", rg_death_notice },
{ "rg_player_relationship", rg_player_relationship },
{ "rg_remove_spawn_protection", rg_remove_spawn_protection },
{ "rg_set_spawn_protection", rg_set_spawn_protection },

{ nullptr, nullptr }
};
Expand Down

0 comments on commit 5ac34ac

Please sign in to comment.