added server command functions
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40528
This commit is contained in:
parent
eb9352b75d
commit
dc06ac6501
@ -477,6 +477,41 @@ static cell_t sm_PrintToConsole(IPluginContext *pCtx, const cell_t *params)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t sm_ServerCommand(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
char buffer[1024];
|
||||
size_t len = g_SourceMod.FormatString(buffer, sizeof(buffer)-2, pContext, params, 1);
|
||||
|
||||
/* One byte for null terminator, one for newline */
|
||||
buffer[len++] = '\n';
|
||||
buffer[len] = '\0';
|
||||
|
||||
engine->ServerCommand(buffer);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t sm_InsertServerCommand(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
char buffer[1024];
|
||||
size_t len = g_SourceMod.FormatString(buffer, sizeof(buffer)-2, pContext, params, 1);
|
||||
|
||||
/* One byte for null terminator, one for newline */
|
||||
buffer[len++] = '\n';
|
||||
buffer[len] = '\0';
|
||||
|
||||
engine->InsertServerCommand(buffer);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t sm_ServerExecute(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
engine->ServerExecute();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
REGISTER_NATIVES(consoleNatives)
|
||||
{
|
||||
{"CreateConVar", sm_CreateConVar},
|
||||
@ -505,5 +540,8 @@ REGISTER_NATIVES(consoleNatives)
|
||||
{"PrintToServer", sm_PrintToServer},
|
||||
{"PrintToConsole", sm_PrintToConsole},
|
||||
{"RegAdminCmd", sm_RegAdminCmd},
|
||||
{"ServerCommand", sm_ServerCommand},
|
||||
{"InsertServerCommand", sm_InsertServerCommand},
|
||||
{"ServerExecute", sm_ServerExecute},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
@ -52,6 +52,30 @@
|
||||
#define FCVAR_NETWORKSYSTEM (1<<26) /**< Defined by the network system. */
|
||||
#define FCVAR_VPHYSICS (1<<27) /**< Defined by vphysics. */
|
||||
|
||||
/**
|
||||
* Executes a server command as if it were on the server console (or RCON)
|
||||
*
|
||||
* @param format Formatting rules.
|
||||
* @param ... Variable number of format parameters.
|
||||
* @noreturn
|
||||
*/
|
||||
native ServerCommand(const String:format[], {Handle,Float,String,_}:...);
|
||||
|
||||
/**
|
||||
* Inserts a server command at the beginning of the server command buffer.
|
||||
*
|
||||
* @param format Formatting rules.
|
||||
* @param ... Variable number of format parameters.
|
||||
* @noreturn
|
||||
*/
|
||||
native InsertServerCommand(const String:format[], {Handle,Float,String,_}:...);
|
||||
|
||||
/**
|
||||
* Executes every command in the server's command buffer, rather than once per frame.
|
||||
*
|
||||
* @noreturn
|
||||
*/
|
||||
native ServerExecute();
|
||||
|
||||
/**
|
||||
* Sends a message to the server console.
|
||||
|
Loading…
Reference in New Issue
Block a user