Sample Plugins (Metamod:Source)

From AlliedModders Wiki
Revision as of 09:42, 9 October 2007 by BAILOPAN (talk | contribs)
Jump to: navigation, search

This guide briefly explains about and how to compile the sample plugins for Metamod:Source.

On Visual Studio 8.0, each plugin contains a "Release" and "Debug" build configuration for both Orange Box and the original engine.

When using GCC, there are two separate makefiles for each engine. For example:

make -f Makefile.ep2 debug

Would build the Orange Box version of that plugin.

Sample Plugins

stub_mm

This plugin is a bare-minimum example of what you need to build a Metamod:Source plugin. It implements the ISmmPlugin class, exposes it as a DLL, and nothing more. As a single example, it also hooks ServerActivate in IServerGameDLL. "Stub" was designed such that a developer could open it and quickly modify it to begin a plugin.

  • stub_mm.cpp - Main plugin file and implementation
  • stub_mm.h - Main plugin header

sample_mm

The sample plugin re-implements Valve's serverplugin_empty sample. It contains demonstrations of hooking events, creating cvars/commands, and displaying dialogs to clients.

  • sample_mm.cpp - Main plugin file and implementation
  • sample_mm.h - Main plugin header
  • engine_wrappers.h - Wrapper functions for abstracting Half-Life engine versions.

Where to Get

You can find the source code to the sample plugins in either the source code package or SVN. For example, using trunk, trunk/sample_mm.

Compiling

Windows

These plugins have been compiled and tested with Microsoft Visual Studio 8.0 (.NET 2005). No earlier version is supported. Before you compile, you must have these directories in your include options. To set these, go to Tools, Options, Projects, VC++ Directories.

  • From the Include Files menu, add these HL2SDK paths:
    • public
    • public/dlls
    • public/engine
    • public/tier0
    • public/tier1
    • public/vstdlib
    • tier1
  • From the Library Files menu, add these HL2SDK paths:
    • lib/public
  • From the Include Files menu, add these SourceMM paths:
    • sourcemm
    • sourcemm/sourcehook
    • sourcemm/sourcemm

You can then open the .vcproj project file. Go to Build, Set Active Configuration, and select Release. You can then select Build from the Build menu, which will produce a .dll file in the Release folder in the project folder.

Linux

To build on Linux, you must have a copy of Source Dedicated Server installed. Open the project Makefile and edit the following lines at the top:

  • SRCDS - Location of main srcds installation
  • SMM_ROOT - Location of folder containing sourcemm and sourcehook
  • HL2SDK - Location of HL2SDK

Once done, you can just type "make -f Makefile.epX" to run the build scripts, where X corresponds to the Half-Life 2 engine version (episode 1 is the older engine, and episode 2 is the Orange Box engine). The binary will appear in ./Release/ for normal builds, or ./Debug/ for debug builds.