View Full Version : ServerCommand and SVC_INTERMISSION

07-05-2016, 08:06 AM
I'm trying to make a map-change command using g_EngineFuncs.ServerCommand and NetworkMessages::SVC_INTERMISSION

First of all: SVC_INTERMISSION hasn't been exposed. It is in the SDK.

"Error, bad server command changelevel stadium4"

const float MAPCHANGE_TIME = 2.0f;

void PluginInit()
g_Module.ScriptInfo.SetContactInfo("Nero @ Svencoop forums");

CClientCommand as_map( "as_map", "Changes the map.", @ASMap, ConCommandFlag::AdminOnly );

void chMap( const string map )
string szCommand;

if( snprintf( szCommand, "changelevel %1", map ) )
g_EngineFuncs.ServerCommand( szCommand );

//g_EngineFuncs.ServerCommand( "changelevel " + map );

void ASMap( const CCommand@ args )
CBasePlayer@ pPlayer = g_ConCommandSystem.GetCurrentPlayer();

if( args.ArgC() != 2 )
g_PlayerFuncs.ClientPrint( pPlayer, HUD_PRINTCONSOLE, ".as_map [mapname]\n" );

if( !g_EngineFuncs.IsMapValid( args.Arg(1) ) )
g_PlayerFuncs.ClientPrint( pPlayer, HUD_PRINTCONSOLE, "[AMXPORTS] MAP_NOT_FOUND\n" );

//NetworkMessage intermission( MSG_ALL, NetworkMessages::SVC_INTERMISSION );

g_Scheduler.SetTimeout( "chMap", MAPCHANGE_TIME, args.Arg(1) );

First I tried
g_EngineFuncs.ServerCommand( "changelevel " + map );

Then I tried
g_EngineFuncs.ServerCommand( "changelevel " + map );

And then I tried formatting the string.
All of the above produce that error. :[

07-05-2016, 09:17 AM
SVC_INTERMISSION was added over a month ago, poke the devs for an update.

You have to append either a newline ("\n") or a semicolon (";") to the end of the command in order for the engine to recognize it as a valid command. It's stupid, i know, but necessary for it to work. Should've probably made the function do that automatically if it wasn't already done (i didn't know about this ridiculous rule when i exposed that function).

07-05-2016, 09:30 AM
Ooooh, thankssssss <3 (yeah that seems kinda silly o.O)

07-05-2016, 03:27 PM
Uhm. have you looked at my MapChangeMenu plugin? It has what you want and there is a comment in there that SVC_INTERMISSION is not exposed yet :P

07-05-2016, 04:37 PM
Ooooh, right you are! Thanks :D