Skip to content

Commit

Permalink
Add natives about pause
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-up committed Jul 14, 2024
1 parent 472d279 commit 89f575c
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
16 changes: 16 additions & 0 deletions reapi/extra/amxmodx/scripting/include/reapi_engine.inc
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,22 @@ native rh_get_net_from(output[], len);
*/
native rh_get_client_connect_time(const index);

/*
* Checks if server paused
*
* @return Returns true if paused, otherwise false.
*/
native bool:rh_is_paused();

/*
* Set server pause state
*
* @param st Pause state, true: server will be paused
*
* @noreturn
*/
native rh_set_paused(const bool:st);

/*
* Checks if a specific entity is fully packed in a given frame for a host client.
*
Expand Down
3 changes: 3 additions & 0 deletions reapi/include/cssdk/engine/rehlds_interfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,7 @@ class IRehldsServerData {
virtual void SetName(const char* name) = 0;
virtual class ISteamGameServer *GetSteamGameServer() = 0;
virtual struct netadr_s *GetNetFrom() = 0;

virtual bool IsPaused() = 0;
virtual void SetPaused(bool state) = 0;
};
31 changes: 31 additions & 0 deletions reapi/src/natives/natives_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3722,6 +3722,35 @@ cell AMX_NATIVE_CALL rh_is_entity_fullpacked(AMX *amx, cell *params)
return FALSE;
}

/*
* Checks if server paused
*
* @return Returns true if paused, otherwise false.
*
* native bool:rh_is_paused();
*/
cell AMX_NATIVE_CALL rh_is_paused(AMX *amx, cell *params)
{
return g_RehldsData->IsPaused() ? TRUE : FALSE;
}

/*
* Set server pause state
*
* @param st pause state
*
* @noreturn
*
* native rh_set_paused(const bool:st);
*/
cell AMX_NATIVE_CALL rh_set_paused(AMX *amx, cell *params)
{
enum { arg_count, arg_st };
g_RehldsData->SetPaused(params[arg_st] != 0);

return TRUE;
}

AMX_NATIVE_INFO Misc_Natives_RH[] =
{
{ "rh_set_mapname", rh_set_mapname },
Expand All @@ -3734,6 +3763,8 @@ AMX_NATIVE_INFO Misc_Natives_RH[] =
{ "rh_get_realtime", rh_get_realtime },
{ "rh_is_entity_fullpacked", rh_is_entity_fullpacked },
{ "rh_get_client_connect_time", rh_get_client_connect_time },
{ "rh_is_paused", rh_is_paused },
{ "rh_set_paused", rh_set_paused },

{ nullptr, nullptr }
};
Expand Down

0 comments on commit 89f575c

Please sign in to comment.