2
0
mirror of https://github.com/rehlds/reapi.git synced 2025-04-13 21:10:18 +03:00

Add new native rh_is_server_paused & rh_set_server_pause (#346)

This commit is contained in:
Eason 2025-04-08 20:24:45 +08:00 committed by GitHub
parent 6dffaef1d5
commit 5c06c04fa7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 63 additions and 2 deletions

View File

@ -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_server_paused();
/*
* Set server pause state
*
* @param status pause state
*
* @noreturn
*
*/
native rh_set_server_pause(const bool:status);
enum MessageHook
{
INVALID_MESSAGEHOOK = 0

View File

@ -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<qboolean, IGameClient*, const void*, unsigned int> 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 {

View File

@ -129,4 +129,14 @@ public:
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;
};

View File

@ -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_server_paused();
*/
cell AMX_NATIVE_CALL rh_is_server_paused(AMX *amx, cell *params)
{
return g_RehldsData->IsPaused() ? TRUE : FALSE;
}
/*
* Set server pause state
*
* @param st pause state
*
* @noreturn
*
* native rh_set_server_pause(const bool:status);
*/
cell AMX_NATIVE_CALL rh_set_server_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_server_paused", rh_is_server_paused },
{ "rh_set_server_pause", rh_set_server_pause },
{ nullptr, nullptr }
};

View File

@ -6,5 +6,5 @@
#pragma once
#define VERSION_MAJOR 5
#define VERSION_MINOR 27
#define VERSION_MINOR 28
#define VERSION_MAINTENANCE 0