From 3c7453f9ed87e9e2c2d796bc4e8487e097a37756 Mon Sep 17 00:00:00 2001 From: Eason Date: Mon, 7 Apr 2025 23:52:20 +0800 Subject: [PATCH 1/2] Add new native `rh_is_paused` & `rh_set_pause` --- .../scripting/include/reapi_engine.inc | 18 +++++++++++ reapi/include/cssdk/engine/rehlds_api.h | 5 +++- .../include/cssdk/engine/rehlds_interfaces.h | 10 +++++++ reapi/src/natives/natives_misc.cpp | 30 +++++++++++++++++++ reapi/version/version.h | 2 +- 5 files changed, 63 insertions(+), 2 deletions(-) diff --git a/reapi/extra/amxmodx/scripting/include/reapi_engine.inc b/reapi/extra/amxmodx/scripting/include/reapi_engine.inc index 1107451a..9fed7e50 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_engine.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_engine.inc @@ -300,6 +300,24 @@ native bool:rh_is_entity_fullpacked(const host, const entity, const frame = -1); */ native Float:rh_get_realtime(); +/* +* Checks if server paused +* +* @return Returns true if paused, otherwise false. +* +*/ +native bool:rh_is_paused(); + +/* +* Set server pause state +* +* @param status pause state +* +* @noreturn +* +*/ +native rh_set_paused(const bool:status); + enum MessageHook { INVALID_MESSAGEHOOK = 0 diff --git a/reapi/include/cssdk/engine/rehlds_api.h b/reapi/include/cssdk/engine/rehlds_api.h index 0444b60c..ac415374 100644 --- a/reapi/include/cssdk/engine/rehlds_api.h +++ b/reapi/include/cssdk/engine/rehlds_api.h @@ -38,7 +38,7 @@ #include "pr_dlls.h" #define REHLDS_API_VERSION_MAJOR 3 -#define REHLDS_API_VERSION_MINOR 14 +#define REHLDS_API_VERSION_MINOR 15 //Steam_NotifyClientConnect hook typedef IHookChain IRehldsHook_Steam_NotifyClientConnect; @@ -434,6 +434,9 @@ struct RehldsFuncs_t { void(*MSG_BeginReading)(); double(*GetHostFrameTime)(); struct cmd_function_s *(*GetFirstCmdFunctionHandle)(); + + // Pause + void(*SetServerPause)(bool status); }; class IRehldsApi { diff --git a/reapi/include/cssdk/engine/rehlds_interfaces.h b/reapi/include/cssdk/engine/rehlds_interfaces.h index e2b909fa..392ae9cc 100644 --- a/reapi/include/cssdk/engine/rehlds_interfaces.h +++ b/reapi/include/cssdk/engine/rehlds_interfaces.h @@ -129,4 +129,14 @@ class IRehldsServerData { virtual void SetName(const char* name) = 0; virtual class ISteamGameServer *GetSteamGameServer() = 0; virtual struct netadr_s *GetNetFrom() = 0; + virtual double GetOldTime() = 0; + + virtual void SetNetFrom(struct netadr_s *from) = 0; + virtual void SetWorldmapCrc(uint32 crcValue) = 0; + virtual void SetDecalNameNum(int num) = 0; + + virtual bool IsActive() = 0; + virtual void SetActive(bool state) = 0; + virtual bool IsPaused() = 0; + virtual void SetPaused(bool state) = 0; }; diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp index 2b60d839..80c950a8 100644 --- a/reapi/src/natives/natives_misc.cpp +++ b/reapi/src/natives/natives_misc.cpp @@ -3761,6 +3761,34 @@ 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_pause(const bool:status); +*/ +cell AMX_NATIVE_CALL rh_set_pause(AMX *amx, cell *params) +{ + enum { arg_count, arg_status }; + g_RehldsFuncs->SetServerPause(params[arg_status] != 0); + return TRUE; +} + AMX_NATIVE_INFO Misc_Natives_RH[] = { { "rh_set_mapname", rh_set_mapname }, @@ -3773,6 +3801,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_pause", rh_set_pause }, { nullptr, nullptr } }; diff --git a/reapi/version/version.h b/reapi/version/version.h index fc64686b..62c33001 100644 --- a/reapi/version/version.h +++ b/reapi/version/version.h @@ -6,5 +6,5 @@ #pragma once #define VERSION_MAJOR 5 -#define VERSION_MINOR 27 +#define VERSION_MINOR 28 #define VERSION_MAINTENANCE 0 From fa7c9d01046862ebf403035426f5452e339c3d21 Mon Sep 17 00:00:00 2001 From: Eason Date: Tue, 8 Apr 2025 19:35:33 +0800 Subject: [PATCH 2/2] update native name --- .../extra/amxmodx/scripting/include/reapi_engine.inc | 4 ++-- reapi/src/natives/natives_misc.cpp | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/reapi/extra/amxmodx/scripting/include/reapi_engine.inc b/reapi/extra/amxmodx/scripting/include/reapi_engine.inc index 9fed7e50..62f752bd 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_engine.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_engine.inc @@ -306,7 +306,7 @@ native Float:rh_get_realtime(); * @return Returns true if paused, otherwise false. * */ -native bool:rh_is_paused(); +native bool:rh_is_server_paused(); /* * Set server pause state @@ -316,7 +316,7 @@ native bool:rh_is_paused(); * @noreturn * */ -native rh_set_paused(const bool:status); +native rh_set_server_pause(const bool:status); enum MessageHook { diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp index 80c950a8..9a18fd32 100644 --- a/reapi/src/natives/natives_misc.cpp +++ b/reapi/src/natives/natives_misc.cpp @@ -3766,9 +3766,9 @@ cell AMX_NATIVE_CALL rh_is_entity_fullpacked(AMX *amx, cell *params) * * @return Returns true if paused, otherwise false. * -* native bool:rh_is_paused(); +* native bool:rh_is_server_paused(); */ -cell AMX_NATIVE_CALL rh_is_paused(AMX *amx, cell *params) +cell AMX_NATIVE_CALL rh_is_server_paused(AMX *amx, cell *params) { return g_RehldsData->IsPaused() ? TRUE : FALSE; } @@ -3780,9 +3780,9 @@ cell AMX_NATIVE_CALL rh_is_paused(AMX *amx, cell *params) * * @noreturn * -* native rh_set_pause(const bool:status); +* native rh_set_server_pause(const bool:status); */ -cell AMX_NATIVE_CALL rh_set_pause(AMX *amx, cell *params) +cell AMX_NATIVE_CALL rh_set_server_pause(AMX *amx, cell *params) { enum { arg_count, arg_status }; g_RehldsFuncs->SetServerPause(params[arg_status] != 0); @@ -3801,8 +3801,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_pause", rh_set_pause }, + { "rh_is_server_paused", rh_is_server_paused }, + { "rh_set_server_pause", rh_set_server_pause }, { nullptr, nullptr } };