Orange Box server plugins

From Valve Developer Community
Jump to: navigation, search


Server plugins for the Orange Box Source engine differ from previous versions.

The instructions below are useful when trying to build plugins prior to the release of the updated Source SDK.

Windows Plugins

Make a copy of the latest Source SDK

You may want to make a separate copy of the current Source SDK and your plugin sources (at least initially) since these changes are not backwards compatible with previous Source engines.

Get updated headers and files

Download the files here and replace these over the files in your Source SDK directories: FTP site download location

Update your project to link against new libs

If not already doing so, change your project to link against the new libs copied into place from the FTP site above.

Make source code modifications

To do: Expand

CON_COMMAND arguments

References to these commands:


are no longer available from the server. Console commands now get their arguments via an extra parameter passed to the CON_COMMAND(). The argument is an instance of the CCommand class and typically is passed as "args" if you use the built-in CON_COMMAND macro. As such, the corresponding code would be (notice the change in case, too):


Registering console commands and variables

The methods for this have changed, too. If your code was based on the serverplugin_empty example that came with the original Source SDK, you can change your serverplugin_convar.cpp to read like this:

#include "icvar.h"
#include "convar.h"

class CPluginConVarAccessor : public IConCommandBaseAccessor
	virtual bool	RegisterConCommandBase( ConCommandBase *pCommand )
		// Link to engine's list
		g_pCVar->RegisterConCommand( pCommand );
		return true;


CPluginConVarAccessor g_ConVarAccessor;
void InitCVars( CreateInterfaceFn cvarFactory )
	g_pCVar = (ICvar*)cvarFactory( CVAR_INTERFACE_VERSION, NULL );
	if ( g_pCVar )
		ConVar_Register(0, &g_ConVarAccessor );

Update your plugin to support all IServerPluginCallbacks


This callback has changed to accept the new CCommand argument for the parsed command:

 virtual PLUGIN_RESULT	ClientCommand( edict_t *pEntity, const CCommand &args );

Fix ConVar change callbacks

The callbacks for ConVar changes have a different signature. Instead of something like this:

 void mycallback ( ConVar *var, char const *pOldString );

You now must conform to this:

 typedef void ( *FnChangeCallback_t )( IConVar *var, const char *pOldValue, float flOldValue );

To do: Add more steps here

Linux Plugins