<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alliedmods.net/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=SaberUK</id>
	<title>AlliedModders Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alliedmods.net/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=SaberUK"/>
	<link rel="alternate" type="text/html" href="https://wiki.alliedmods.net/Special:Contributions/SaberUK"/>
	<updated>2026-05-25T19:11:12Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.6</generator>
	<entry>
		<id>https://wiki.alliedmods.net/index.php?title=SRCDS_Hardening&amp;diff=8190</id>
		<title>SRCDS Hardening</title>
		<link rel="alternate" type="text/html" href="https://wiki.alliedmods.net/index.php?title=SRCDS_Hardening&amp;diff=8190"/>
		<updated>2011-08-14T11:59:41Z</updated>

		<summary type="html">&lt;p&gt;SaberUK: Link to a non broken password generator.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Securing your server = &lt;br /&gt;
== General Tips == &lt;br /&gt;
* Do not enable sv_cheats, do not run any plugins that do so.&lt;br /&gt;
* [http://www.pctools.com/guides/password/ Use secure passwords.]  This should be obvious, but your clan name is not a good rcon password, nor is &amp;quot;password&amp;quot;.&lt;br /&gt;
* Don't blindly give admin out.  Depending on what flags you give people, you could allow them to take over the server.&lt;br /&gt;
* Don't piss people off.  Many servers get attacked because players get pissed off that admins are abusing them.&lt;br /&gt;
&lt;br /&gt;
== File Permissions ==&lt;br /&gt;
If you are running your own server (not renting one from a GSP), there are some things you can do to prevent many of the more malicious exploits.  The basic theory here is to give srcds as little access to the machine as possible.  It only needs write access to the following directories:&lt;br /&gt;
* downloads/&lt;br /&gt;
* cache/&lt;br /&gt;
* addons/sourcemod/gamedata/&lt;br /&gt;
* addons/sourcemod/data/&lt;br /&gt;
* addons/sourcemod/logs/&lt;br /&gt;
* logs/&lt;br /&gt;
Note that some plugins rely on being able to write to directories other then these, and permissions may break them.  At the very least, it's a good idea to make sure srcds is running as a user that does not have permission to change anything outside of it's own directory.  That will prevent your machine from being comprised and made into a botnet client.&lt;br /&gt;
&lt;br /&gt;
== Linux File Permission Setup ==&lt;br /&gt;
&lt;br /&gt;
Create a unprivileged users to run the server.&lt;br /&gt;
&lt;br /&gt;
'''useradd -m -s /bin/bash -d /home/srcds srcds'''&lt;br /&gt;
&lt;br /&gt;
* useradd = Linux command to add users&lt;br /&gt;
* -m = Creates the user's home directory if it does not exist.&lt;br /&gt;
* -s /bin/bash = Users login shell ( if you are not sure what this should be leave it blank)&lt;br /&gt;
* -d /home/srcds = Location of users home directory.&lt;br /&gt;
&lt;br /&gt;
Set a password for the account make sure it is secure.&lt;br /&gt;
&lt;br /&gt;
'''passwd srcds'''&lt;br /&gt;
&lt;br /&gt;
* passwd srcds = Linux change password command&lt;br /&gt;
&lt;br /&gt;
Now move your existing srcds install to the new home dir or do a fresh install.&lt;br /&gt;
&lt;br /&gt;
'''cp -r /path/to/old/install /path/to/new/users/home''' &lt;br /&gt;
&lt;br /&gt;
*cp = Linux copy command&lt;br /&gt;
&lt;br /&gt;
'''chown -R srcds:scrds'''&lt;br /&gt;
&lt;br /&gt;
* chown = Linux command to change owner of files&lt;br /&gt;
* -R = Changes all the directory you are in and all subdirectories&lt;br /&gt;
&lt;br /&gt;
The last things you want to do is make the files read only and run the srcds as the new user.&lt;br /&gt;
&lt;br /&gt;
'''chmod -R 444 * /path/to/srcds/'''&lt;br /&gt;
&lt;br /&gt;
*chmod = Linux change permission command&lt;br /&gt;
* -R = Change files and directories recursively&lt;br /&gt;
* 444 = Read only&lt;br /&gt;
* &amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; = wild card[http://www.tuxfiles.org/linuxhelp/wildcards.html]&lt;br /&gt;
&lt;br /&gt;
Now you need to make the files mentioned above to read and write and a few exec.&lt;br /&gt;
&lt;br /&gt;
Read Write (chmod 644):&lt;br /&gt;
* downloads/&lt;br /&gt;
* cache/&lt;br /&gt;
* addons/sourcemod/gamedata/&lt;br /&gt;
* addons/sourcemod/data/&lt;br /&gt;
* addons/sourcemod/logs/&lt;br /&gt;
* logs/&lt;br /&gt;
&lt;br /&gt;
Read and exec (cmond 744):&lt;br /&gt;
* /orangebox/srcds_linux&lt;br /&gt;
* /orangebox/srcds_run&lt;br /&gt;
&lt;br /&gt;
== Plugins ==&lt;br /&gt;
There are a few plugins that can be installed to prevent exploits.  Some of the recommended ones include [https://forums.alliedmods.net/showthread.php?p=841590 Rcon locker / exploit fix], [https://forums.alliedmods.net/showthread.php?p=779851 Forlix FloodCheck], [https://forums.alliedmods.net/showthread.php?t=109453 D-FENS], and [http://www.sourceop.com/modules.php?name=Downloads&amp;amp;d_op=viewdownload&amp;amp;cid=9 DAF].&lt;br /&gt;
&lt;br /&gt;
Many of the Eventscripts plugins that claim to fix exploits are mostly useless at best, or actively harmful to your server at worst.  If you are running the plugins listed in the previous paragraph, you do not need anything else to protect your server.  Installing extra plugins other then those will likely cause issues with your server, and is not recommended.&lt;br /&gt;
&lt;br /&gt;
= Current Exploits =&lt;br /&gt;
&lt;br /&gt;
== Crashes ==&lt;br /&gt;
&lt;br /&gt;
=== Invalid RCON Crash ===&lt;br /&gt;
SRCDS will crash on some machines if you attempt to use an incorrect rcon password too many times.  It seems that some machines are affected by this, while others are not.  Valve has been notified a few times, and has been unwilling/unable to fix this.&lt;br /&gt;
&lt;br /&gt;
*Fix: Firewall off rcon (TCP port 27015) from everyone except for certain whitelisted IP's.&lt;br /&gt;
&lt;br /&gt;
=== HalfConnected Crash ===&lt;br /&gt;
If a command is received as the client is connecting, the server will crash or enter a state where it does not accept new connections, but has not crashed.  This exploit can also happen if you remove the players entity, which shouldn't happen under normal circumstances.  Valve has been notified, and is unwilling to fix this.&lt;br /&gt;
&lt;br /&gt;
*Fix: [https://forums.alliedmods.net/showthread.php?p=841590 Rcon locker / exploit fix]&lt;br /&gt;
&lt;br /&gt;
=== Disconnect Crash ===&lt;br /&gt;
Using modified clients, it is possible to send disconnect messages with large numbers of special characters.  These have a variety of effects, including crashing the server or crashing all connected clients.&lt;br /&gt;
&lt;br /&gt;
*Fix: [https://forums.alliedmods.net/showthread.php?p=841590 Rcon locker / exploit fix]&lt;br /&gt;
&lt;br /&gt;
=== &amp;quot;K&amp;quot; packet Crash ===&lt;br /&gt;
Using modified clients, it is possible to send a Steam auth packet that contains an invalid header length.  Upon receiving this packet, the server will crash.&lt;br /&gt;
&lt;br /&gt;
*Fix: 4/19/10: Apply the latest steam beta patch.  Run hldsupdatetool with &amp;quot;-beta cs0419&amp;quot; to get this.&lt;br /&gt;
&lt;br /&gt;
== Takeover == &lt;br /&gt;
=== ent_fire server takeover ===&lt;br /&gt;
If cheats are enabled on a server, the point_servercommand entity can be created, which can be used by clients to execute rcon commands on the server.  Premade scripts exist for this that will change the rcon password, and add the client as an admin.  Valve has been notified, and is unwilling to fix this.&lt;br /&gt;
&lt;br /&gt;
*Fix: [https://forums.alliedmods.net/showthread.php?p=841590 Rcon locker / exploit fix] will prevent the rcon password from being changed, as well as disallowing the point_servercommand entity.  The alternative is to not run with sv_cheats 1, and take other measures to ensure it is never enabled.&lt;br /&gt;
=== ES_Tools changelevel exploit ===&lt;br /&gt;
The &amp;quot;changelevel&amp;quot; command can be abused when ES_tools is running to execute commands on the server&lt;br /&gt;
&lt;br /&gt;
*Fix: [https://forums.alliedmods.net/showthread.php?p=841590 Rcon locker / exploit fix] will prevent this.  Alternatively, remove es_tools if at all possible.&lt;br /&gt;
=== File upload/download ===&lt;br /&gt;
It's possible to convince the server to let you upload or download random files from it.  Valve has been attempting to fix this, but there still seem to be some workarounds to their fixes.&lt;br /&gt;
&lt;br /&gt;
If you are running your own servers (not rented from a GSP), you can set file permissions on them to fix the upload issue.&lt;br /&gt;
&lt;br /&gt;
*Fix: [https://forums.alliedmods.net/showthread.php?t=109453 dfens] will prevent this.&lt;br /&gt;
&lt;br /&gt;
== Lag/DOS ==&lt;br /&gt;
=== A2C_PRINT Spam ===&lt;br /&gt;
SRCDS does not do any sort of authentication on A2C_PRINT messages.  This means that anyone can print messages to the servers console, simply by sending UDP packets.  It seems this is a legacy feature, and is not actually used by anything. Valve has been notified, and doesn't see this as a problem.&lt;br /&gt;
&lt;br /&gt;
*Fix: Block any packets beginning with \xFF\xFF\xFF\xFF\x6C or run [http://www.sourceop.com/modules.php?name=Downloads&amp;amp;d_op=viewdownload&amp;amp;cid=9 DAF]&lt;br /&gt;
=== A2S_INFO Spam ===&lt;br /&gt;
If large numbers of A2S_INFO packets are sent at the server, the FPS will severely drop, making the server essentially unplayable.  Since these packets can be spoofed, rate limiting one IP is fairly useless&lt;br /&gt;
&lt;br /&gt;
*Fix: You can use sv_max_queries_sec_global to limit this, though that would mean your server would be invisible on the master server list while the attacks are in progress.  [https://forums.alliedmods.net/showthread.php?t=114787 Query Cache] (a SM extension) will also work.&lt;br /&gt;
*'''Fixed in:''' TF2 (partial fix) (August 13, 2009)&lt;br /&gt;
&lt;br /&gt;
=== Command spam ===&lt;br /&gt;
Various commands built into the game can be spammed to lag or crash the server.  Some of these commands can cause the ingame physiscs to freeze up.  The fix for most of these is quite simple, just disable them by adding the cheats flag. Valve has been notified, and fixes commands in the occasional patch.&lt;br /&gt;
&lt;br /&gt;
*Fix: [https://forums.alliedmods.net/showthread.php?p=779851 Forlix FloodCheck] can be used to kick players who have been caught spamming, [https://forums.alliedmods.net/showthread.php?p=841590 Rcon locker / exploit fix] adds the cheats flag to most of the known commands.  [https://forums.alliedmods.net/showthread.php?p=880328 Scortched Earth] will disable all commands except for those on a whitelist, which is the &amp;quot;better&amp;quot; way to fix this, but can break other addons.&lt;br /&gt;
&lt;br /&gt;
=== Bell characters in name ===&lt;br /&gt;
If your name contains bell characters, this can be used to lag the server on windows.&lt;br /&gt;
&lt;br /&gt;
Fix: [https://forums.alliedmods.net/showthread.php?p=841590 Rcon locker / exploit fix] will kick players with these characters in their name.&lt;br /&gt;
=== Force fullupdate ===&lt;br /&gt;
If you send an empty packet to the server, you can force it to send you the full state of the game, which will lag the server if done enough.  Valve has been notified, and is unwilling to fix this.&lt;br /&gt;
&lt;br /&gt;
*Fix: [http://www.sourceop.com/modules.php?name=Downloads&amp;amp;d_op=viewdownload&amp;amp;cid=9 DAF] has a partial workaround&lt;br /&gt;
&lt;br /&gt;
== Annoyances ==&lt;br /&gt;
=== Teleport exploit ===&lt;br /&gt;
If you use very large values for your mouse sensitivity, you can overwrite your X and Y coordinates, letting you teleport around.  This has the potential to crash the server as well.  Valve has been notified, and is unwilling to fix this.&lt;br /&gt;
&lt;br /&gt;
*Fix: [https://forums.alliedmods.net/showthread.php?p=841590 Rcon locker / exploit fix] has a partial fix for this.&lt;br /&gt;
*'''Fixed in:''' TF2 (July 14 2009)&lt;br /&gt;
=== Clientside plugins ===&lt;br /&gt;
The VSP interface built into the game can be used to load plugins on the game client, allowing them to change cheat-flagged cvars.  This can allow them to have wallhacks, or alter weapon recharge rates.  Valve has been notified, and is unwilling to fix this.&lt;br /&gt;
&lt;br /&gt;
*Fix: [https://forums.alliedmods.net/showthread.php?p=841590 Rcon locker / exploit fix] has a partial fix for this.&lt;br /&gt;
=== Empty name / unconnected ===&lt;br /&gt;
Players can set their name to an empty string using the setinfo console command.  Some admin plugins will be unable to kick or perform other actions on them.  Valve has been notified, and is unwilling to fix this.&lt;br /&gt;
&lt;br /&gt;
*Fix: [https://forums.alliedmods.net/showthread.php?p=841590 Rcon locker / exploit fix] will automatically kick anyone found to have an empty name&lt;br /&gt;
=== Special name characters ===&lt;br /&gt;
If certain special characters are added to your name, you can create messages that appear to be sent by the server administrator.&lt;br /&gt;
&lt;br /&gt;
*Fix: [https://forums.alliedmods.net/showthread.php?p=841590 Rcon locker / exploit fix]&lt;br /&gt;
&lt;br /&gt;
= Fixed Exploits = &lt;br /&gt;
== Memory corruption crash ==&lt;br /&gt;
See [http://aluigi.altervista.org/adv/sourcefraghof-adv.txt this link]&lt;br /&gt;
&lt;br /&gt;
Fix: none&lt;br /&gt;
*'''Fixed in:''' Orangebox, L4D (August 21 2009) CSS (August 25 2009)&lt;br /&gt;
&lt;br /&gt;
== Arbitrary file upload ==&lt;br /&gt;
See [http://aluigi.altervista.org/adv/sourceupfile-adv.txt this link]&lt;br /&gt;
&lt;br /&gt;
Fix: [https://forums.alliedmods.net/showthread.php?p=905647 File upload exploit fix]&lt;br /&gt;
*'''Fixed in:''' Orangebox, L4D (August 21 2009) CSS (August 25 2009)&lt;br /&gt;
&lt;br /&gt;
== &amp;quot;ProcessClientInfo: SourceTV can not connect to game directly&amp;quot; crash ==&lt;br /&gt;
See [http://aluigi.altervista.org/adv/sourcenotvnull-adv.txt this link]&lt;br /&gt;
&lt;br /&gt;
Fix: Add &amp;quot;tv_enable 1&amp;quot; to cfg/autoexec.cfg, and (optionally) &amp;quot;tv_enable 0&amp;quot; to server.cfg (You only need tv_enable 0 if you don't want sourcetv)&lt;br /&gt;
*'''Fixed in:''' Orangebox, L4D (August 21 2009) CSS (August 25 2009)&lt;br /&gt;
&lt;br /&gt;
== Player disconnect crash ==&lt;br /&gt;
See [http://aluigi.altervista.org/adv/sourcefs-adv.txt this link]&lt;br /&gt;
&lt;br /&gt;
Fix: [https://forums.alliedmods.net/showthread.php?p=841590 Rcon locker / exploit fix] has what may be a partial fix. &lt;br /&gt;
*'''Fixed in:''' Orangebox, L4D (August 21 2009) CSS (August 25 2009)&lt;/div&gt;</summary>
		<author><name>SaberUK</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.alliedmods.net/index.php?title=Metamod:Source_Development&amp;diff=7903</id>
		<title>Metamod:Source Development</title>
		<link rel="alternate" type="text/html" href="https://wiki.alliedmods.net/index.php?title=Metamod:Source_Development&amp;diff=7903"/>
		<updated>2010-12-15T16:00:40Z</updated>

		<summary type="html">&lt;p&gt;SaberUK: Half-Life 2: Deathmatch now uses the Orange Box engine.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is an introduction to coding for Metamod:Source.  The main article of importance is [[SourceHook Development]].  Additional information can be found in the sample and stub plugins found in the Metamod:Source source code distribution.&lt;br /&gt;
&lt;br /&gt;
If you find this article to be a tough read, you may want to skip over to the [[Sample Plugins (Metamod:Source)|Sample Plugins]] article.  See also setting up a [[Metamod:Source Environment]].  Note that Metamod:Source is a C++ platform, and you should have an intermediate knowledge of C++ (or, at the least, a strong will to research what's in the SDK).&lt;br /&gt;
&lt;br /&gt;
=Differences from Valve Plugins=&lt;br /&gt;
A Valve Server Plugin has more out-of-box callbacks than a Metamod:Source plugin, but:&lt;br /&gt;
*A Valve Server Plugin cannot opt-out of those callbacks.  They must be implemented, even if as empty functions.&lt;br /&gt;
*A Valve Server Plugin cannot hook or override any function not explicitly marked as one of its callbacks.  It can do so by using low-level hacks, or by embedding SourceHook, but this sets up a conflict where plugins are vying to alter and override the same memory addresses.&lt;br /&gt;
&lt;br /&gt;
Thus, Metamod:Source has two goals:&lt;br /&gt;
*Resolve the hooking conflicts by creating a centralized, run-time hooking system.&lt;br /&gt;
*Create a standardized, easy, and flexible API to abstract the process of hooking functions.&lt;br /&gt;
&lt;br /&gt;
As an example of this, a Valve Server Plugin has about 13 callbacks, 3 of which can be overridden.  A Metamod:Source plugin can safely hook any virtual function in the SDK, and override/supersede each of them as it pleases.&lt;br /&gt;
&lt;br /&gt;
While a stub Metamod:Source plugin may look bare, it is easy to re-implement the functionality provided by &amp;lt;tt&amp;gt;IServerPluginCallbacks&amp;lt;/tt&amp;gt;, and this is done so in the [[Sample Plugins (Metamod:Source)|Sample Plugins]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Plugin API=&lt;br /&gt;
Metamod:Source has two separate APIs:&lt;br /&gt;
*[http://www.metamodsource.net/dox-1.4.3/ 1.4 API], contained in &amp;lt;tt&amp;gt;core-legacy&amp;lt;/tt&amp;gt;.  This is the API you should use if you're building a plugin to run on the following Source engines:&lt;br /&gt;
**Original (The Ship)&lt;br /&gt;
**Episode 1 (Older third party mods).&lt;br /&gt;
*[http://www.metamodsource.net/dox/ 1.6 API], contained in &amp;lt;tt&amp;gt;core&amp;lt;/tt&amp;gt;.  This is the API you should use if you're building against the following Source engines:&lt;br /&gt;
**Orange Box (Garry's Mod, Newer third party mods)&lt;br /&gt;
**Orange Box Valve (Team Fortress, Day of Defeat, CS:S, HL2:DM)&lt;br /&gt;
**Left 4 Dead &lt;br /&gt;
**Left 4 Dead 2&lt;br /&gt;
**Alien Swarm&lt;br /&gt;
&lt;br /&gt;
It is important to get this right.  The two APIs are not compatible, and if you wish to write a plugin that work across all engines, you must take special care in your plugin as a few API calls were renamed along the way.&lt;br /&gt;
&lt;br /&gt;
More information is available in the article [[MM:S API Differences]].&lt;br /&gt;
&lt;br /&gt;
=Starting a plugin=&lt;br /&gt;
See [[Metamod:Source Environment]] to set up your build environment.&lt;br /&gt;
&lt;br /&gt;
In order to write a plugin, you must implement the ISmmPlugin interface, similar to IServerPluginCallbacks.  An example of implementing this can be seen in the &amp;lt;tt&amp;gt;stub_mm&amp;lt;/tt&amp;gt; sample plugin.&lt;br /&gt;
&lt;br /&gt;
Once you've implemented the interface, you must also have a global singleton of your plugin available. There are a few macros to assist you in properly exposing the interface as a DLL and setting up the API states.&lt;br /&gt;
&lt;br /&gt;
*{{bcode|PLUGIN_GLOBALVARS}}() - Place in header. Declares the global variables that some API calls require (such as g_SHPtr and g_PLAPI).&lt;br /&gt;
*{{bcode|PLUGIN_EXPOSE}}(class, singleton) - Place in .cpp file. Declares the external CreateInterface function which exposes the API.&lt;br /&gt;
*{{bcode|PLUGIN_SAVEVARS}}() - Use first thing in ISmmPlugin::Load(), saves the global variables sent from SourceMM.&lt;br /&gt;
&lt;br /&gt;
Full documentation of each callback is available in the &amp;lt;tt&amp;gt;ISmmPlugin.h&amp;lt;/tt&amp;gt; header file.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=SourceHook=&lt;br /&gt;
Using SourceHook is fully covered in the [[SourceHook Development]] article.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Various Macros=&lt;br /&gt;
*{{bcode|META_CONPRINT}}(const char *msg)&lt;br /&gt;
*{{bcode|META_CONPRINTF}}(const char *fmt, ...)&lt;br /&gt;
**These two functions are equivalent to ConMsg().&lt;br /&gt;
*{{bcode|META_LOG}}(g_PLAPI, const char *msg, ...)&lt;br /&gt;
**Logs a message through IVEngineServer::LogPrint(). A newline is automatically added, and msg is formatted as a sprintf() style string. Logging is done by the game server and can be enabled by adding ''log on'' to server.cfg or typing it in the console. The log files are found in the logs directory of the particular MOD you are running.&lt;br /&gt;
*{{bcode|META_REGCVAR}}(var)&lt;br /&gt;
**Registers a ConCommandBase pointer through Metamod:Source.&lt;br /&gt;
*{{bcode|META_UNREGCVAR}}(var)&lt;br /&gt;
**Unregisters a ConCommandBase pointer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Metamod Events=&lt;br /&gt;
The Metamod Events System is based on IMetamodListener. By implementing the IMetamodListener class and using g_SMAPI-&amp;gt;AddListener, you can watch for certain, low-traffic events. These events are split into three categories:&lt;br /&gt;
&lt;br /&gt;
*Plugin Events let you listen for plugin pauses and unloads. This is important if you're relying on information from another plugin, as you can handle cases where a live plugin has become invalid.&lt;br /&gt;
*Game Events are simple events that Metamod:Source is already hooking and makes available. These are LevelShutdown and LevelInit right now.&lt;br /&gt;
*Query Events occur when a factory is used. The four main factories (Engine, GameDLL, FileSystem, and Physics) are all overridable. You should simply return a non-NULL result to override, and fill the return code with IFACE_OK if available. There is no way to handle the case of two plugins overriding right now. The final factory is the Metamod Factory, which is the factory that Metamod:Source adds to the runtime space for plugins. By default, it only contains the interfaces for the PluginManager and SourceHook. Plugins can use this to add new interfaces. Other plugins request these interfaces through g_SMAPI-&amp;gt;MetaFactory().&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Global Variables=&lt;br /&gt;
These global variables are saved by PLUGIN_EXPOSE and PLUGIN_SAVEVARS. They are declared with PLUGIN_GLOBALVARS.&lt;br /&gt;
&lt;br /&gt;
*{{bcode|g_PLAPI}}&lt;br /&gt;
**ISmmPlugin * pointer to your global class singleton.&lt;br /&gt;
*{{bcode|g_PLID}}&lt;br /&gt;
**The internal PluginId of your plugin.&lt;br /&gt;
*{{bcode|g_SHPtr}}&lt;br /&gt;
**The SourceHook::ISourceHook * pointer to SourceHook's interface.&lt;br /&gt;
*{{bcode|g_SMAPI}}&lt;br /&gt;
**The ISmmAPI * pointer to Metamod:Source's interface.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Interface Searching=&lt;br /&gt;
&amp;lt;tt&amp;gt;ISmmAPI::VInterfaceMatch()&amp;lt;/tt&amp;gt; can be used for searching for an interface..  This simplified version corrects the design flaw in InterfaceSearch() whereby passing an unmodified INTERFACEVERSION string would only search interfaces later than or equal to that version.  For example, &amp;lt;tt&amp;gt;INTERFACEVERSION_SERVERGAMEDLL&amp;lt;/tt&amp;gt; being &amp;quot;ServerGameDLL005&amp;quot; would not find a GameDLL using ServerGameDLL004.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;VInterfaceMatch()&amp;lt;/tt&amp;gt; removes the &amp;quot;max&amp;quot; parameter from &amp;lt;tt&amp;gt;InterfaceSearch()&amp;lt;/tt&amp;gt; and adds an optional &amp;quot;chop&amp;quot; parameter, which specifices whether or not the interface should be searched from the beginning (default) or from the current version.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=VSP Interface Hooking=&lt;br /&gt;
Metamod:Source can provide a &amp;quot;virtual&amp;quot; [[Valve Server Plugin]] plugin interface.  This is useful for providing an &amp;lt;tt&amp;gt;IServerPluginCallbacks&amp;lt;/tt&amp;gt; pointer to certain routines, or hooking functions it has.&lt;br /&gt;
&lt;br /&gt;
Example: (Note that GetVSPInfo is for Metamod:Source 1.6+)&lt;br /&gt;
&amp;lt;cpp&amp;gt;SH_DECL_HOOK2(IServerPluginCallbacks, NetworkIDValidated, SH_NOATTRIB, 0, PLUGIN_RESULT, const char *, const char *);&lt;br /&gt;
&lt;br /&gt;
IServerPluginCallbacks *vsp_iface = NULL;&lt;br /&gt;
&lt;br /&gt;
bool Plugin::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)&lt;br /&gt;
{&lt;br /&gt;
    if ((vsp_iface = ismm-&amp;gt;GetVSPInfo(NULL)) == NULL)&lt;br /&gt;
    {&lt;br /&gt;
      ismm-&amp;gt;EnableVSPListener();&lt;br /&gt;
      ismm-&amp;gt;AddListener(this, this);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Plugin::OnVSPListening(IServerPluginCallbacks *iface)&lt;br /&gt;
{&lt;br /&gt;
    SH_ADD_HOOK_MEMFUNC(IServerPluginCallbacks, NetworkIDValidated, iface, &amp;amp;g_Plugin, &amp;amp;Plugin::NetworkIDValidated, false);&lt;br /&gt;
    vsp_iface = iface;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
PLUGIN_RESULT Plugin::NetworkIDValidated(const char *pszUserName, const char *pszNetworkID)&lt;br /&gt;
{&lt;br /&gt;
    META_CONPRINTF(&amp;quot;%s has been validated with Network ID %s\n&amp;quot;, pszUserName, pszNetworkID);&lt;br /&gt;
    RETURN_META_VALUE(MRES_SUPERCEDE, PLUGIN_CONTINUE);&lt;br /&gt;
}&amp;lt;/cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=User Message Enumeration=&lt;br /&gt;
API functions have also been added for the purpose of enumerating user messages.  These serve to replace &amp;lt;tt&amp;gt;IServerGameDLL::GetUserMessageInfo()&amp;lt;/tt&amp;gt; which can crash the server upon passing an invalid message index.  The new functions include: &lt;br /&gt;
*&amp;lt;tt&amp;gt;GetUserMessageCount()&amp;lt;/tt&amp;gt;&lt;br /&gt;
*&amp;lt;tt&amp;gt;FindUserMessage()&amp;lt;/tt&amp;gt;&lt;br /&gt;
*&amp;lt;tt&amp;gt;GetUserMessage()&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a quick example of how to use them:&lt;br /&gt;
&amp;lt;cpp&amp;gt;// Get index of 'SayText' message&lt;br /&gt;
int msgSayText = g_SMAPI-&amp;gt;FindUserMessage(&amp;quot;SayText&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// Get number of user messages in GameDLL&lt;br /&gt;
int count = g_SMAPI-&amp;gt;GetUserMessageCount();&lt;br /&gt;
&lt;br /&gt;
const char *name;&lt;br /&gt;
int size;&lt;br /&gt;
&lt;br /&gt;
// Print list of user message names and sizes&lt;br /&gt;
for (int i = 0; i &amp;lt; count; i++)&lt;br /&gt;
{&lt;br /&gt;
    name = g_SMAPI-&amp;gt;GetUserMessage(i, &amp;amp;size);&lt;br /&gt;
&lt;br /&gt;
    META_CONPRINTF(&amp;quot;Message %d: (name \&amp;quot;%s\&amp;quot;) (size %d)\n&amp;quot;, i, name, size);&lt;br /&gt;
}&amp;lt;/cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Compiling=&lt;br /&gt;
==Linux==&lt;br /&gt;
See [[Sample Plugins (Metamod:Source)|Sample Plugins]] and [[Metamod:Source Environment]] for getting sample Makefiles and setting up your build environment.&lt;br /&gt;
&lt;br /&gt;
There are a few GCC flags that you should not remove, or if you're writing a new Makefile, you should consider using:&lt;br /&gt;
*&amp;lt;tt&amp;gt;-Wall&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;-Werror&amp;lt;/tt&amp;gt; - These help ensure a minimal amount of accidental coding mistakes.  Unless you absolutely refuse to fix warnings, it is a good idea to make sure your code compiles flawlessly.  Note that Valve does not build with these options, and many mistakes are masked in the SDK because of it.  If you use Valve's SDK instead of our fixed copy, you will not be able to use &amp;lt;tt&amp;gt;-Werror&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*&amp;lt;tt&amp;gt;-Wno-non-virtual-dtor&amp;lt;/tt&amp;gt; - This is kind of a useless warning from GCC (not all classes need destructors).&lt;br /&gt;
*&amp;lt;tt&amp;gt;-fno-exceptions&amp;lt;/tt&amp;gt; - You should not use exceptions because this creates a &amp;lt;tt&amp;gt;libstdc++&amp;lt;/tt&amp;gt; dependency.&lt;br /&gt;
*&amp;lt;tt&amp;gt;-fno-strict-aliasing&amp;lt;/tt&amp;gt; - By default, GCC does not allow certain type casts which were perfectly legal in previous versions, and are perfectly legal in almost every other C/C++ compiler.  These type casts are prevalent and without this option, GCC '''will''' generate incorrect code.&lt;br /&gt;
&lt;br /&gt;
There are a few flags you should generally not add, ever:&lt;br /&gt;
*&amp;lt;tt&amp;gt;-lstdc++&amp;lt;/tt&amp;gt; (same as using &amp;lt;tt&amp;gt;g++&amp;lt;/tt&amp;gt;) - Even if you use the exact same compiler build as Valve, linking against the &amp;lt;tt&amp;gt;libstdc++&amp;lt;/tt&amp;gt; will be painful.  Not all Linux distributions use the same version, and in general ABI compatibility on this library is frequently broken.  You will find that users report load failures or even crashes, and the problem may be very difficult to trace.  As such, you should avoid using exceptions or any part of the Standard Template Library (STL).  Valve provides many abstractions that should suffice, and SourceHook provides some as well.&lt;br /&gt;
**''Note:'' Statically linking to &amp;lt;tt&amp;gt;libstdc++&amp;lt;/tt&amp;gt; is not an option.  It will cause many problems.&lt;br /&gt;
*&amp;lt;tt&amp;gt;-m64&amp;lt;/tt&amp;gt; - Don't try to build 64-bit software off the SDK.  Valve doesn't even have a 64-bit port of the server yet.&lt;br /&gt;
&lt;br /&gt;
==Windows==&lt;br /&gt;
For Visual Studio, there are a few project options which are required.  All of these settings are in the &amp;quot;Project Properties&amp;quot; dialog (under the Project menu).&lt;br /&gt;
&lt;br /&gt;
*Configuration Properties -&amp;gt; General&lt;br /&gt;
**&amp;quot;Character Set&amp;quot; should be &amp;quot;Use Multi-Byte Character Set,&amp;quot; '''not''' Unicode.&lt;br /&gt;
*Configuration Properties -&amp;gt; C/C++&lt;br /&gt;
**General&lt;br /&gt;
***&amp;quot;Detect 64-bit Portability Issues&amp;quot; should be &amp;quot;No,&amp;quot; unless you like (mostly) pointless warnings.&lt;br /&gt;
**Preprocessor&lt;br /&gt;
***&amp;quot;Processor Defines&amp;quot; -- You should add &amp;lt;tt&amp;gt;_CRT_SECURE_NO_DEPRECATE&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;_CRT_NONSTDC_NO_DEPRECATE&amp;lt;/tt&amp;gt; to the semicolon-delimited list.  Microsoft decided to &amp;quot;deprecate&amp;quot; a bunch of Standard C API calls, apparently not noticing that people like to use them.  Use these macros to stop the compiler from throwing a hissy-fit.&lt;br /&gt;
**Code Generation&lt;br /&gt;
***&amp;quot;Runtime&amp;quot; Library should be &amp;quot;Multi-threaded Debug&amp;quot; or &amp;quot;Multi-threaded&amp;quot; depending on the configuration.  You should not use the DLL version, as this will link against &amp;lt;tt&amp;gt;MSVCRT80[D]&amp;lt;/tt&amp;gt;, which is part of the redistributable framework (and not packaged with Windows).&lt;br /&gt;
&lt;br /&gt;
For sample linking and include folders, you should see [[Sample Plugins (Metamod:Source)]].  Sample Visual Studio project files are provided with everything you'd need.&lt;br /&gt;
&lt;br /&gt;
[[Category:SourceHook]]&lt;br /&gt;
[[Category:Metamod:Source Development]]&lt;/div&gt;</summary>
		<author><name>SaberUK</name></author>
		
	</entry>
</feed>