PDA

View Full Version : Allowed server commands?



Julcoool
17-04-2016, 01:27 PM
void ServerCommand(const string& in szCommand)

Issues a command to the server. Plugins only.


Which commands are we allowed to use? A list would be nice.

Solokiller
17-04-2016, 02:18 PM
The commands you give it are given straight to the engine, so whatever is allowed by it. I'm not aware of any list of allowed commands, if anybody made one before it should apply here.

Julcoool
17-04-2016, 02:42 PM
Umm...



File@ static_file = g_FileSystem.OpenFile( "scripts/plugins/static.cfg", OpenFile::READ );

if ( static_file !is null && static_file.IsOpen() )
{
string line;

while ( !static_file.EOFReached() )
{
static_file.ReadLine( line );
if ( line.Length() == 0 || line[ 0 ] == '/' || line[ 0 ] == '/' && line[ 1 ] == '/' )
continue;

array< string >@ pre_cvar = line.Split( ' ' );
pre_cvar[ 0 ].Trim();
pre_cvar[ 1 ].Trim();

if ( IsCvarAllowed( pre_cvar[ 0 ] ) )
{
string post_cvar;
post_cvar += "" + pre_cvar[ 0 ] + " " + pre_cvar[ 1 ];
g_Game.AlertMessage( at_console, "* DEBUG: post_cvar = " + post_cvar + "\n" );
g_EngineFuncs.ServerCommand( post_cvar );
}
}
}


Sending mp_npckill 2 via file, console says...


Error, bad server command mp_npckill 2

Unless I should send the command with quotes?

Solokiller
17-04-2016, 02:53 PM
You shouldn't use ServerCommand to set cvars. Use g_EngineFuncs.CVarSetFloat instead. If you do want to use ServerCommand, you'll have to append a newline ("\n") so the engine allows it.

Julcoool
17-04-2016, 03:11 PM
...Oops. That should do.