Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add natives about pause #324

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 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,27 @@ 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, false: unpause(if paused)
* @param host If it is 1, the native will call 'Host_Pause()'
*
* @note rh_set_paused(true, true) just like set pausable to 1 and execute client command 'pause'
* @note rh_set_paused(true, false) only set g_psv.paused
* @note It's best not to use rh_set_paused(false, false), bad things will happen
*
* @noreturn
*/
native rh_set_pause(const bool:st, const bool:host = true);

/*
* Checks if a specific entity is fully packed in a given frame for a host client.
*
Expand Down
1 change: 1 addition & 0 deletions reapi/include/cssdk/engine/rehlds_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ struct RehldsFuncs_t {
void(*RemoveExtDll)(void *hModule);
void(*RemoveCvarListener)(const char *var_name, cvar_callback_t func);
ENTITYINIT(*GetEntityInit)(char *pszClassName);
void(*Host_Pause)(bool setPause);

// Read functions
int(*MSG_ReadChar)();
Expand Down
10 changes: 10 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,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;

jonathan-up marked this conversation as resolved.
Show resolved Hide resolved
virtual bool IsPaused() = 0;
virtual void SetPaused(bool state) = 0;
};
36 changes: 36 additions & 0 deletions reapi/src/natives/natives_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3722,6 +3722,40 @@ 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;
jonathan-up marked this conversation as resolved.
Show resolved Hide resolved
}

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

g_RehldsData->SetPaused(isPause);
if (params[arg_host] != 0)
{
g_RehldsFuncs->Host_Pause(isPause);
}
return TRUE;
}

AMX_NATIVE_INFO Misc_Natives_RH[] =
{
{ "rh_set_mapname", rh_set_mapname },
Expand All @@ -3734,6 +3768,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 }
};
Expand Down
Loading