Sample Plugins (Metamod:Source)

From AlliedModders Wiki
Revision as of 21:28, 17 February 2008 by BAILOPAN (talk | contribs)
Jump to: navigation, search

Metamod:Source comes with two sample plugins: stub and sample. This article is a brief overview of how to read and compile them. They are intended as a baseline for developing your own plugins.

Metamod:Source is a C++ environment, but this is not a C++ tutorial. You should have sufficient knowledge of computer organization (memory, pointers, addressing) and intermediate experience with C++. Most importantly, you should be willing to dive into header files to research API definitions (which is necessary for the HL2SDK regardless).


Before you begin, you should set up your Metamod:Source Environment. If you fail to complete this step, it is unlikely much else in this article will work for you.

The two sample plugins provided are:

  • stub_mm - Bare-bones plugin that does almost nothing.
  • sample_mm - More filling example plugin which implements a few things that Valve's serverplugin_sample does, such as hooking functions, creating ConVars, console commands, and showing dialog boxes.

The Engine Divide

The Orange Box and Episode 1 engines are not compatible, and thus there is a division:

  • Metamod:Source 1.4/Episode 1
  • Metamod:Source 1.6/Orange Box

Unfortunately, there is a "lag period" where not all games have moved to the new engine. It is likely that this lag period will continue for at least another twelve months (this writing is as of February 2008). As such, we are writing all of our plugin code such that it compiles against both platforms. It is your choice whether to do this as well. As the usage of Metamod:Source 1.4 and the original engine decays, we will begin removing the legacy cruft from the sample plugins.



Both plugins have a Visual Studio 2005 project file in their msvc8 folders. Each plugin has four build modes:

  • Release - Orange Box - Release mode, Orange Box, MM:S 1.6
  • Debug - Orange Box - Debug mode, Orange Box, MM:S 1.6
  • Release - Original - Release mode, Original/Episode1, MM:S 1.4
  • Debug - Original - Debug mode, Original/Episode1, MM:S 1.4

There exists normal "Release" and "Debug" build modes -- you should not use them, as they are not configured.


On Linux, you cannot simply type "make" in the folder containing the Makefile. You must specify a combination of parameters:

  • ENGINE - Required. Must be either "orangebox" or "original".
  • DEBUG - Optional. Can be empty (Release mode) or "true" (Debug mode).

Binaries and object files will be written to one of the following folders:

  • Release.orangebox
  • Debug.orangebox
  • Release.original
  • Debug.original

Examples of building one of the example plugins:

#MM:S 1.4/Episode 1, debug mode
make DEBUG=true ENGINE=original
#MM:S 1.6/Orange Box, release mode
make ENGINE=orangebox
#Cleaning the MM:S 1.4 build
make clean ENGINE=original

Note that you may need to edit the folder locations at the top of the Makefile, in case you set up your paths differently.