Skip to content

Commit 5c06c04

Browse files
authored
Add new native rh_is_server_paused & rh_set_server_pause (#346)
1 parent 6dffaef commit 5c06c04

5 files changed

Lines changed: 63 additions & 2 deletions

File tree

reapi/extra/amxmodx/scripting/include/reapi_engine.inc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,24 @@ native bool:rh_is_entity_fullpacked(const host, const entity, const frame = -1);
300300
*/
301301
native Float:rh_get_realtime();
302302

303+
/*
304+
* Checks if server paused
305+
*
306+
* @return Returns true if paused, otherwise false.
307+
*
308+
*/
309+
native bool:rh_is_server_paused();
310+
311+
/*
312+
* Set server pause state
313+
*
314+
* @param status pause state
315+
*
316+
* @noreturn
317+
*
318+
*/
319+
native rh_set_server_pause(const bool:status);
320+
303321
enum MessageHook
304322
{
305323
INVALID_MESSAGEHOOK = 0

reapi/include/cssdk/engine/rehlds_api.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#include "pr_dlls.h"
3939

4040
#define REHLDS_API_VERSION_MAJOR 3
41-
#define REHLDS_API_VERSION_MINOR 14
41+
#define REHLDS_API_VERSION_MINOR 15
4242

4343
//Steam_NotifyClientConnect hook
4444
typedef IHookChain<qboolean, IGameClient*, const void*, unsigned int> IRehldsHook_Steam_NotifyClientConnect;
@@ -434,6 +434,9 @@ struct RehldsFuncs_t {
434434
void(*MSG_BeginReading)();
435435
double(*GetHostFrameTime)();
436436
struct cmd_function_s *(*GetFirstCmdFunctionHandle)();
437+
438+
// Pause
439+
void(*SetServerPause)(bool status);
437440
};
438441

439442
class IRehldsApi {

reapi/include/cssdk/engine/rehlds_interfaces.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,14 @@ class IRehldsServerData {
129129
virtual void SetName(const char* name) = 0;
130130
virtual class ISteamGameServer *GetSteamGameServer() = 0;
131131
virtual struct netadr_s *GetNetFrom() = 0;
132+
virtual double GetOldTime() = 0;
133+
134+
virtual void SetNetFrom(struct netadr_s *from) = 0;
135+
virtual void SetWorldmapCrc(uint32 crcValue) = 0;
136+
virtual void SetDecalNameNum(int num) = 0;
137+
138+
virtual bool IsActive() = 0;
139+
virtual void SetActive(bool state) = 0;
140+
virtual bool IsPaused() = 0;
141+
virtual void SetPaused(bool state) = 0;
132142
};

reapi/src/natives/natives_misc.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3761,6 +3761,34 @@ cell AMX_NATIVE_CALL rh_is_entity_fullpacked(AMX *amx, cell *params)
37613761
return FALSE;
37623762
}
37633763

3764+
/*
3765+
* Checks if server paused
3766+
*
3767+
* @return Returns true if paused, otherwise false.
3768+
*
3769+
* native bool:rh_is_server_paused();
3770+
*/
3771+
cell AMX_NATIVE_CALL rh_is_server_paused(AMX *amx, cell *params)
3772+
{
3773+
return g_RehldsData->IsPaused() ? TRUE : FALSE;
3774+
}
3775+
3776+
/*
3777+
* Set server pause state
3778+
*
3779+
* @param st pause state
3780+
*
3781+
* @noreturn
3782+
*
3783+
* native rh_set_server_pause(const bool:status);
3784+
*/
3785+
cell AMX_NATIVE_CALL rh_set_server_pause(AMX *amx, cell *params)
3786+
{
3787+
enum { arg_count, arg_status };
3788+
g_RehldsFuncs->SetServerPause(params[arg_status] != 0);
3789+
return TRUE;
3790+
}
3791+
37643792
AMX_NATIVE_INFO Misc_Natives_RH[] =
37653793
{
37663794
{ "rh_set_mapname", rh_set_mapname },
@@ -3773,6 +3801,8 @@ AMX_NATIVE_INFO Misc_Natives_RH[] =
37733801
{ "rh_get_realtime", rh_get_realtime },
37743802
{ "rh_is_entity_fullpacked", rh_is_entity_fullpacked },
37753803
{ "rh_get_client_connect_time", rh_get_client_connect_time },
3804+
{ "rh_is_server_paused", rh_is_server_paused },
3805+
{ "rh_set_server_pause", rh_set_server_pause },
37763806

37773807
{ nullptr, nullptr }
37783808
};

reapi/version/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
#pragma once
77

88
#define VERSION_MAJOR 5
9-
#define VERSION_MINOR 27
9+
#define VERSION_MINOR 28
1010
#define VERSION_MAINTENANCE 0

0 commit comments

Comments
 (0)