<?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=Impact123</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=Impact123"/>
	<link rel="alternate" type="text/html" href="https://wiki.alliedmods.net/Special:Contributions/Impact123"/>
	<updated>2026-05-09T13:27:26Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.6</generator>
	<entry>
		<id>https://wiki.alliedmods.net/index.php?title=Reserved_Slots_(SourceMod)&amp;diff=11440</id>
		<title>Reserved Slots (SourceMod)</title>
		<link rel="alternate" type="text/html" href="https://wiki.alliedmods.net/index.php?title=Reserved_Slots_(SourceMod)&amp;diff=11440"/>
		<updated>2023-06-14T21:28:24Z</updated>

		<summary type="html">&lt;p&gt;Impact123: Fix wrong config path&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Languages|Reserved Slots (SourceMod)}}&lt;br /&gt;
==Cvars==&lt;br /&gt;
&lt;br /&gt;
*[[#Reserve Type|sm_reserve_type &amp;lt;0|1|2&amp;gt;]]&lt;br /&gt;
*[[#Reserved Slots|sm_reserved_slots &amp;lt;#&amp;gt;]]&lt;br /&gt;
*[[#Hidden Slots|sm_hide_slots &amp;lt;0|1&amp;gt;]]&lt;br /&gt;
*[[#Max Admins|sm_reserve_maxadmins &amp;lt;#&amp;gt;]]&lt;br /&gt;
*[[#Kick Type|sm_reserve_kicktype &amp;lt;0|1|2&amp;gt;]]&lt;br /&gt;
&lt;br /&gt;
You can edit these in the &amp;lt;code&amp;gt;cfg/sourcemod.cfg&amp;lt;/code&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
==Reserve Type==&lt;br /&gt;
&lt;br /&gt;
sm_reserve_type &amp;lt;0|1|2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This controls how reserve slots work on the server (the default is 0).&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;sm_reserve_type 0&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Public slots are used in preference to reserved slots. Reserved slots are freed before public slots.&lt;br /&gt;
No players are ever kicked and once reserved slots are filled by a reserve slot player (and the rest of the server is full) they will remain occupied until a player leaves.&lt;br /&gt;
The use of this is that there can always be at least one admin (assuming you only give reserved slots to admins) on the server at any time. If players inform you that there is a cheater on the server, at least one admin should be able to get it and do something about it.&lt;br /&gt;
If a player without reserve slot access joins when there are only reserved spaces remaining they will be kicked from the server.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;sm_reserve_type 1&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If someone with reserve access joins into a reserved slot, the player with the highest latency and without reserve access (spectator players are selected first) is kicked to make room. Thus, the reserved slots always remain free. The only situation where the reserved slot(s) can become properly occupied is if the server is full with reserve slot access clients. &lt;br /&gt;
This is for servers that want some people to have playing preference over other. With this method admins could one by one join a full server until they all get in.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;sm_reserve_type 2&amp;lt;/tt&amp;gt; - Only available in SourceMod 1.1 or higher.&lt;br /&gt;
&lt;br /&gt;
The same as sm_reserve_type 1 except once a certain number of admins have been reached the reserve slot stops kicking people and anyone can join to fill the server.&lt;br /&gt;
You can use this to simulate having a large number of reserved slots with sm_reserve_type 0 but with only need to have 1 slot unavailable when there are less admins connected.&lt;br /&gt;
&lt;br /&gt;
==Reserved Slots==&lt;br /&gt;
&lt;br /&gt;
sm_reserved_slots &amp;lt;#&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This controls how many slots get reserved by the plugin (the default is 0). &lt;br /&gt;
&lt;br /&gt;
Using sm_reserve_type 0 this is how many admins can join the server after it appears full to the public.&lt;br /&gt;
Using sm_reserve_type 1 this is how many slots are saved for swapping admins in (you shouldn't need more than one)&lt;br /&gt;
&lt;br /&gt;
==Hidden Slots==&lt;br /&gt;
&lt;br /&gt;
sm_hide_slots &amp;lt;0|1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This controls the plugin hides the reserved slots (the default is 0).&lt;br /&gt;
&lt;br /&gt;
If enabled (1) reserve slots are hidden in the server browser window when they are not in use. For example a 24 player server with 2 reserved slots will show as a 22 player server (until the reserved slots are occupied). If you experience that the slots are not hidden, despite setting sm_hide_slots to 1, then adding host_info_show 2 to your server.cfg may solve this problem. &lt;br /&gt;
To connect to the reserved slot of a server that shows as full you will need to use 'connect ip:port' in console. (e.g. 'connect 192.168.1.100:27015').&lt;br /&gt;
&lt;br /&gt;
There is no possible way for the reserved slots to be visible to admins and hidden from normal users. Admin authentication can only happen after the user is fully connected to the server and their steam id is available to SourceMod. For this reason it is often better to hide the slots otherwise public users will attempt to join the server and will get kicked again (rendering the ‘autojoin’ feature useless)&lt;br /&gt;
&lt;br /&gt;
==Max Admins==&lt;br /&gt;
&lt;br /&gt;
sm_reserve_maxadmins &amp;lt;#&amp;gt; - Only available in SourceMod 1.1 or higher.&lt;br /&gt;
&lt;br /&gt;
This controls how many admins can join the server before the reserved slots are made public (only relevant to sm_reserve_type 2) &lt;br /&gt;
&lt;br /&gt;
==Kick Type==&lt;br /&gt;
&lt;br /&gt;
sm_reserve_kicktype &amp;lt;0|1|2&amp;gt; - Only available in SourceMod 1.1 or higher.&lt;br /&gt;
&lt;br /&gt;
This controls how a client is selected to be kicked (only relevant to sm_reserve_type 1/2)&lt;br /&gt;
&lt;br /&gt;
Clients with reserve slot access or the override 'sm_reskick_immunity' are always immune to being kicked. Spectating clients are chosen before playing clients.&lt;br /&gt;
&lt;br /&gt;
0 - Highest Ping&amp;lt;br&amp;gt;&lt;br /&gt;
1 - Highest Connection Time&amp;lt;br&amp;gt;&lt;br /&gt;
2 - Random Player&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Immunity==&lt;br /&gt;
&lt;br /&gt;
To make players immune from being kicked by the reserved slots plugin they need to have access to the override 'sm_reskick_immunity' (users with root or reserved slot access are already immune).&lt;br /&gt;
&lt;br /&gt;
NB: This is only relevant when using sm_reserve_type 1/2.&lt;br /&gt;
&lt;br /&gt;
You can either assign this override to a flag using admin_overrides.cfg (e.g. &amp;quot;sm_reskick_immunity&amp;quot; &amp;quot;o&amp;quot; - to give all users with flag 'o' (custom flag 1) immunity from being kicked)&lt;br /&gt;
&lt;br /&gt;
Or&lt;br /&gt;
&lt;br /&gt;
Give groups access to the overrides in admin_groups.cfg (e.g. &amp;quot;sm_reskick_immunity&amp;quot; &amp;quot;allow&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Then add your VIP members or other users you wish to be immune from being kicked as admins with either the flag you specified or as members of the group you gave access to. (You can create a group with 0 flags and ‘0’ normal immunity and only this override if you don't want them to have any other privileges) &lt;br /&gt;
&lt;br /&gt;
Full details on overriding command access can be found at [[Overriding Command Access (SourceMod)]]&lt;br /&gt;
&lt;br /&gt;
==Possible Future Additions==&lt;br /&gt;
&lt;br /&gt;
These are possible feature additions that have been requested and are under consideration for inclusion in later versions of SourceMod&lt;br /&gt;
&lt;br /&gt;
*Choice to redirect players instead of kicking.&lt;br /&gt;
&lt;br /&gt;
[[Category:SourceMod Documentation|Categories]]&lt;/div&gt;</summary>
		<author><name>Impact123</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.alliedmods.net/index.php?title=Installing_Metamod:Source&amp;diff=11400</id>
		<title>Installing Metamod:Source</title>
		<link rel="alternate" type="text/html" href="https://wiki.alliedmods.net/index.php?title=Installing_Metamod:Source&amp;diff=11400"/>
		<updated>2023-01-14T07:59:35Z</updated>

		<summary type="html">&lt;p&gt;Impact123: Change tt to code and rlaborate where metamod-fatal.log can be found&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article will guide you through a [[Metamod:Source]] installation.&lt;br /&gt;
&lt;br /&gt;
=Normal Installation=&lt;br /&gt;
&lt;br /&gt;
Valve sometimes makes changes in their games that break Metamod:Source between releases.  When this happens, you may need to install a snapshot versions of Metamod:Source.  You can see if this is required on the [[Required Versions (SourceMod)|Required Versions]] page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.metamodsource.net/ Download] Metamod:Source.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Extract the package to your game folder.  For example, for Counter-Strike:Source, you would have &amp;lt;code&amp;gt;cstrike/addons/metamod&amp;lt;/code&amp;gt; after extracting.  If you are uploading to FTP, extract the files locally before transferring to your server's game folder.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Restart your server.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Type &amp;quot;meta version&amp;quot; in your server console (or RCON).  You should see a line like: &amp;quot;Loaded As: Valve Server Plugin.&amp;quot;  If the command is not recognized, see the sections below.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When using a Linux server, you may see the following messages:&lt;br /&gt;
&lt;br /&gt;
* An error indicating that it could not be loaded due to &amp;quot;wrong ELF class: ELFCLASS64&amp;quot;.  If you are using a 32-bit dedicated server installation, this is normal behavior; as long as &amp;lt;code&amp;gt;meta version&amp;lt;/code&amp;gt; is recognized, Metamod:Source is installed.&lt;br /&gt;
* An error indicating that it could not be loaded because &amp;quot;/path/to/server_install/bin/libgcc_s.so.1: version `GCC_7.0.0` not found (required by /some_system_path_to/libstdc++.so.6&amp;quot;.  This is because Valve ships their own copies of those libraries.  As modern systems will have newer versions, you can safely delete the listed file from the server install.  Do not delete the file in the system path (usually &amp;lt;code&amp;gt;lib&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;lib32&amp;lt;/code&amp;gt;).&lt;br /&gt;
* If you are running a 64-bit operating system yourself, you may need to install the system's 32-bit libraries.&lt;br /&gt;
** On Debian / Ubuntu, you can do this with &amp;lt;code&amp;gt;apt install gcc-multilib&amp;lt;/code&amp;gt;.&lt;br /&gt;
* You may find more information about any load failures under a &amp;lt;code&amp;gt;metamod-fatal.log&amp;lt;/code&amp;gt; in metamod's &amp;lt;code&amp;gt;bin&amp;lt;/code&amp;gt; folder.&lt;br /&gt;
&lt;br /&gt;
==Custom VDF File==&lt;br /&gt;
'''Note: This is normally not needed - Metamod:Source 1.10.0 and later include a &amp;lt;code&amp;gt;metamod.vdf&amp;lt;/code&amp;gt; file for easier installation on most games.'''&lt;br /&gt;
&lt;br /&gt;
If you have trouble getting it to load, [http://www.metamodsource.net/?go=vdf go here] to generate a VDF file specific to your game. This file should be placed into your server's &amp;lt;code&amp;gt;addons&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
Known setups that require this step:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Left 4 Dead 1&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;3rd party mods using the Source SDK Base.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Listen servers (created with the in-game &amp;quot;Create Server&amp;quot; option) for non-english game clients.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=GameInfo=&lt;br /&gt;
'''Note: This is normally not needed - if you do not understand what this is, do NOT do this unless instructed to. The above instructions are sufficient to install Metamod:Source for 99% of servers.'''&lt;br /&gt;
&lt;br /&gt;
Metamod:Source 1.4.2 and lower used an older method for loading itself.  The advantage of this method was that Metamod:Source could be loaded before the actual game mod, which gave it a small amount of extra functionality.  This functionality was never used by plugin developers, and Steam updates kept overwriting &amp;lt;code&amp;gt;gameinfo.txt&amp;lt;/code&amp;gt; files, so we switched to a different loading mechanism.&lt;br /&gt;
&lt;br /&gt;
However this loading mechanism may still be desirable if you run into backwards compatibility issues, or you have a plugin which takes advantage of the early-loading mechanism.  If this is your case, here are the &amp;lt;code&amp;gt;gameinfo.txt&amp;lt;/code&amp;gt; directions below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Open the file in the mod folder called &amp;quot;gameinfo.txt&amp;quot;. You will see a few lines at the bottom like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
SearchPaths&lt;br /&gt;
{&lt;br /&gt;
	Game				|gameinfo_path|. &lt;br /&gt;
	Game				cstrike&lt;br /&gt;
	Game				hl2&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Add a line after the &amp;quot;{&amp;quot; sign but before all of the &amp;quot;Game&amp;quot; entries that looks like this:&amp;lt;pre&amp;gt;GameBin				|gameinfo_path|addons/metamod/bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;If you're using Windows, you may need to use a backwards slash (\) instead.&lt;br /&gt;
&amp;lt;li&amp;gt;You're done! To test whether it worked, restart your game server and type &amp;quot;meta version&amp;quot; in the server console.  You should see a line that says &amp;quot;Loaded as: GameDLL (gameinfo.txt).&amp;quot;  If it doesn't recognize the command, the installation probably failed.  If the &amp;quot;Loaded as:&amp;quot; line says something else, &amp;lt;code&amp;gt;gameinfo.txt&amp;lt;/code&amp;gt; was probably not modified correctly.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;For more information or documentation, see [[:Category:Metamod:Source Documentation]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;gameinfo.txt&amp;lt;/code&amp;gt; loading method is supported as a legacy feature only.  The patcher tool is no longer provided.  You can mark &amp;lt;code&amp;gt;gameinfo.txt&amp;lt;/code&amp;gt; if you absolutely want to protect it from being overwritten.&lt;br /&gt;
&lt;br /&gt;
We will continue to make sure Metamod:Source can load via this method for as long as the Source Engine allows it.  However, we will concentrate more on supporting the new loading mechanism for general use.&lt;br /&gt;
&lt;br /&gt;
[[Category:Metamod:Source Documentation]]&lt;/div&gt;</summary>
		<author><name>Impact123</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.alliedmods.net/index.php?title=Reserved_Slots_(SourceMod)&amp;diff=11294</id>
		<title>Reserved Slots (SourceMod)</title>
		<link rel="alternate" type="text/html" href="https://wiki.alliedmods.net/index.php?title=Reserved_Slots_(SourceMod)&amp;diff=11294"/>
		<updated>2022-05-13T21:26:45Z</updated>

		<summary type="html">&lt;p&gt;Impact123: Add note about where to change the ConVars&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Languages|Reserved Slots (SourceMod)}}&lt;br /&gt;
==Cvars==&lt;br /&gt;
&lt;br /&gt;
*[[#Reserve Type|sm_reserve_type &amp;lt;0|1|2&amp;gt;]]&lt;br /&gt;
*[[#Reserved Slots|sm_reserved_slots &amp;lt;#&amp;gt;]]&lt;br /&gt;
*[[#Hidden Slots|sm_hide_slots &amp;lt;0|1&amp;gt;]]&lt;br /&gt;
*[[#Max Admins|sm_reserve_maxadmins &amp;lt;#&amp;gt;]]&lt;br /&gt;
*[[#Kick Type|sm_reserve_kicktype &amp;lt;0|1|2&amp;gt;]]&lt;br /&gt;
&lt;br /&gt;
You can edit these in the &amp;lt;code&amp;gt;configs/cfg/sourcemod.cfg&amp;lt;/code&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
==Reserve Type==&lt;br /&gt;
&lt;br /&gt;
sm_reserve_type &amp;lt;0|1|2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This controls how reserve slots work on the server (the default is 0).&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;sm_reserve_type 0&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Public slots are used in preference to reserved slots. Reserved slots are freed before public slots.&lt;br /&gt;
No players are ever kicked and once reserved slots are filled by a reserve slot player (and the rest of the server is full) they will remain occupied until a player leaves.&lt;br /&gt;
The use of this is that there can always be at least one admin (assuming you only give reserved slots to admins) on the server at any time. If players inform you that there is a cheater on the server, at least one admin should be able to get it and do something about it.&lt;br /&gt;
If a player without reserve slot access joins when there are only reserved spaces remaining they will be kicked from the server.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;sm_reserve_type 1&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If someone with reserve access joins into a reserved slot, the player with the highest latency and without reserve access (spectator players are selected first) is kicked to make room. Thus, the reserved slots always remain free. The only situation where the reserved slot(s) can become properly occupied is if the server is full with reserve slot access clients. &lt;br /&gt;
This is for servers that want some people to have playing preference over other. With this method admins could one by one join a full server until they all get in.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;sm_reserve_type 2&amp;lt;/tt&amp;gt; - Only available in SourceMod 1.1 or higher.&lt;br /&gt;
&lt;br /&gt;
The same as sm_reserve_type 1 except once a certain number of admins have been reached the reserve slot stops kicking people and anyone can join to fill the server.&lt;br /&gt;
You can use this to simulate having a large number of reserved slots with sm_reserve_type 0 but with only need to have 1 slot unavailable when there are less admins connected.&lt;br /&gt;
&lt;br /&gt;
==Reserved Slots==&lt;br /&gt;
&lt;br /&gt;
sm_reserved_slots &amp;lt;#&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This controls how many slots get reserved by the plugin (the default is 0). &lt;br /&gt;
&lt;br /&gt;
Using sm_reserve_type 0 this is how many admins can join the server after it appears full to the public.&lt;br /&gt;
Using sm_reserve_type 1 this is how many slots are saved for swapping admins in (you shouldn't need more than one)&lt;br /&gt;
&lt;br /&gt;
==Hidden Slots==&lt;br /&gt;
&lt;br /&gt;
sm_hide_slots &amp;lt;0|1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This controls the plugin hides the reserved slots (the default is 0).&lt;br /&gt;
&lt;br /&gt;
If enabled (1) reserve slots are hidden in the server browser window when they are not in use. For example a 24 player server with 2 reserved slots will show as a 22 player server (until the reserved slots are occupied).&lt;br /&gt;
To connect to the reserved slot of a server that shows as full you will need to use 'connect ip:port' in console. (e.g. 'connect 192.168.1.100:27015')&lt;br /&gt;
&lt;br /&gt;
There is no possible way for the reserved slots to be visible to admins and hidden from normal users. Admin authentication can only happen after the user is fully connected to the server and their steam id is available to SourceMod. For this reason it is often better to hide the slots otherwise public users will attempt to join the server and will get kicked again (rendering the ‘autojoin’ feature useless)&lt;br /&gt;
&lt;br /&gt;
==Max Admins==&lt;br /&gt;
&lt;br /&gt;
sm_reserve_maxadmins &amp;lt;#&amp;gt; - Only available in SourceMod 1.1 or higher.&lt;br /&gt;
&lt;br /&gt;
This controls how many admins can join the server before the reserved slots are made public (only relevant to sm_reserve_type 2) &lt;br /&gt;
&lt;br /&gt;
==Kick Type==&lt;br /&gt;
&lt;br /&gt;
sm_reserve_kicktype &amp;lt;0|1|2&amp;gt; - Only available in SourceMod 1.1 or higher.&lt;br /&gt;
&lt;br /&gt;
This controls how a client is selected to be kicked (only relevant to sm_reserve_type 1/2)&lt;br /&gt;
&lt;br /&gt;
Clients with reserve slot access or the override 'sm_reskick_immunity' are always immune to being kicked. Spectating clients are chosen before playing clients.&lt;br /&gt;
&lt;br /&gt;
0 - Highest Ping&amp;lt;br&amp;gt;&lt;br /&gt;
1 - Highest Connection Time&amp;lt;br&amp;gt;&lt;br /&gt;
2 - Random Player&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Immunity==&lt;br /&gt;
&lt;br /&gt;
To make players immune from being kicked by the reserved slots plugin they need to have access to the override 'sm_reskick_immunity' (users with root or reserved slot access are already immune).&lt;br /&gt;
&lt;br /&gt;
NB: This is only relevant when using sm_reserve_type 1/2.&lt;br /&gt;
&lt;br /&gt;
You can either assign this override to a flag using admin_overrides.cfg (e.g. &amp;quot;sm_reskick_immunity&amp;quot; &amp;quot;o&amp;quot; - to give all users with flag 'o' (custom flag 1) immunity from being kicked)&lt;br /&gt;
&lt;br /&gt;
Or&lt;br /&gt;
&lt;br /&gt;
Give groups access to the overrides in admin_groups.cfg (e.g. &amp;quot;sm_reskick_immunity&amp;quot; &amp;quot;allow&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Then add your VIP members or other users you wish to be immune from being kicked as admins with either the flag you specified or as members of the group you gave access to. (You can create a group with 0 flags and ‘0’ normal immunity and only this override if you don't want them to have any other privileges) &lt;br /&gt;
&lt;br /&gt;
Full details on overriding command access can be found at [[Overriding Command Access (SourceMod)]]&lt;br /&gt;
&lt;br /&gt;
==Possible Future Additions==&lt;br /&gt;
&lt;br /&gt;
These are possible feature additions that have been requested and are under consideration for inclusion in later versions of SourceMod&lt;br /&gt;
&lt;br /&gt;
*Choice to redirect players instead of kicking.&lt;br /&gt;
&lt;br /&gt;
[[Category:SourceMod Documentation|Categories]]&lt;/div&gt;</summary>
		<author><name>Impact123</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.alliedmods.net/index.php?title=Introduction_to_SourcePawn_1.7&amp;diff=11227</id>
		<title>Introduction to SourcePawn 1.7</title>
		<link rel="alternate" type="text/html" href="https://wiki.alliedmods.net/index.php?title=Introduction_to_SourcePawn_1.7&amp;diff=11227"/>
		<updated>2021-08-15T15:54:37Z</updated>

		<summary type="html">&lt;p&gt;Impact123: Add example for {x, ...} Syntax&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide is designed to give you a very basic overview to fundamentals of scripting in SourcePawn. [[Pawn]] is a &amp;quot;scripting&amp;quot; language used to embed functionality in other programs. That means it is not a standalone language, like C++ or Java, and its details will differ based on the application. SourcePawn is the version of Pawn used in [[SourceMod]].&lt;br /&gt;
&lt;br /&gt;
This guide does not tell you how to write SourceMod plugins; it is intended as an overview of the syntax and semantics of the language instead. Read the separate article, [[Introduction to SourceMod Plugins]] for SourceMod API specifics. &lt;br /&gt;
&lt;br /&gt;
=Non-Programmer Intro=&lt;br /&gt;
This section is intended for non-programmers. If you're still confused, you may want to pick up a book on another language, such as PHP, Python, or Java, to get a better idea of what programming is like.&lt;br /&gt;
&lt;br /&gt;
==Symbols/Keywords==&lt;br /&gt;
A symbol is a series of letters, numbers, and/or underscores, that uniquely represents something. Symbols are case-sensitive, and usually start with a letter.&lt;br /&gt;
&lt;br /&gt;
There are a few reserved symbols that have special meaning. For example, &amp;lt;tt&amp;gt;if&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;for&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;return&amp;lt;/tt&amp;gt; are special constructs in the language that will explained later. They cannot be used as symbol names.&lt;br /&gt;
&lt;br /&gt;
==Variables==&lt;br /&gt;
There a few important constructs you should know before you begin to script. The first is a '''variable'''. A variable is a symbol, or name, that holds data. For example, the variable &amp;quot;a&amp;quot; could hold the number &amp;quot;2&amp;quot;, &amp;quot;16&amp;quot;, &amp;quot;0&amp;quot;, et cetera. Since a variable holds data, it also allocates the memory needed to store that data.&lt;br /&gt;
&lt;br /&gt;
In addition to a name, variables have a '''type'''. A type tells the program how to interpret the data, and how much memory the data will use. Pawn has four types of data that are most commonly used:&lt;br /&gt;
* Integers, using the &amp;lt;tt&amp;gt;int&amp;lt;/tt&amp;gt; type. Integer types may store a whole number from -2147483648 to 2147483647.&lt;br /&gt;
* Floats, using the &amp;lt;tt&amp;gt;float&amp;lt;/tt&amp;gt; type. Float types may store fractional numbers in a huge range, though they are not as precise as integers.&lt;br /&gt;
* Characters, using the &amp;lt;tt&amp;gt;char&amp;lt;/tt&amp;gt; type. Character types store one byte of character information, typically an [http://www.asciitable.com/ ASCII] character.&lt;br /&gt;
* Booleans, using the &amp;lt;tt&amp;gt;bool&amp;lt;/tt&amp;gt; type. Booleans store either true or false.&lt;br /&gt;
&lt;br /&gt;
Example of creating variables and assigning values:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;int money = 5400;&lt;br /&gt;
float percent = 67.3;&lt;br /&gt;
char key = 'A';&lt;br /&gt;
bool enabled = false;&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
The next important concept is '''functions'''. Functions are symbols or names that perform an action. When you invoke, or call them, they carry out a specific sequence of code and then return a result. There are a few types of functions, but every function is activated the same way. Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
show(56);     // Calls the &amp;quot;show&amp;quot; function, and gives it the number 56.&lt;br /&gt;
enable();     // Calls the &amp;quot;enable&amp;quot; function with no values.&lt;br /&gt;
bool visible = show(a);    //Calls the &amp;quot;show&amp;quot; function, stores its result in a variable.&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every piece of data passed to a function is called a '''parameter'''. A function can have any number of parameters (there is a &amp;quot;reasonable&amp;quot; limit of 32 in SourceMod). Parameters will be explained further in the article.&lt;br /&gt;
&lt;br /&gt;
==Comments==&lt;br /&gt;
Note any text that appears after a &amp;quot;//&amp;quot; is considered a &amp;quot;comment&amp;quot; and is not actual code. There are two comment styles:&lt;br /&gt;
*&amp;lt;tt&amp;gt;//&amp;lt;/tt&amp;gt; - Double slash, everything following on that line is ignored.&lt;br /&gt;
*&amp;lt;tt&amp;gt;/* */&amp;lt;/tt&amp;gt; - Multi-line comment, everything in between the asterisks is ignored. You cannot nest these.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Block Coding==&lt;br /&gt;
The next concept is block coding. You can group code into &amp;quot;blocks&amp;quot; separated by { and }. This effectively makes one large block of code act as one statement. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;{&lt;br /&gt;
   here;&lt;br /&gt;
   is;&lt;br /&gt;
   some;&lt;br /&gt;
   code;&lt;br /&gt;
}&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block coding using braces is used everywhere in programming. Blocks of code can be nested within each other. It is a good idea to adapt a consistent and readable indentation style early on to prevent spaghetti-looking code.&lt;br /&gt;
&lt;br /&gt;
=Language Paradigms=&lt;br /&gt;
Pawn may seem similar to other languages, like C, but it has fundamental differences. It is not important that you immediately understand these differences, but they may be helpful if you're familiar with another language already.&lt;br /&gt;
*'''Pawn is sort of typed.''' Before SourceMod 1.7, Pawn did not have types. Older code and older natives will reflect this by using tags and the &amp;lt;tt&amp;gt;new&amp;lt;/tt&amp;gt; keyword. As of SourceMod 1.7, we recommend that all code use types. For more information see [[SourcePawn Transitional Syntax]].&lt;br /&gt;
*'''Pawn is not garbage collected.''' Pawn, as a language, has no built-in memory allocation, and thus has no garbage. If a function allocates memory, you may be responsible for freeing it.&lt;br /&gt;
*'''Pawn is not object oriented.''' Pawn does not have structs or objects. As of SourceMod 1.7, it has limited sugaring for treating some data types as objects, but users cannot create their own objects or classes.&lt;br /&gt;
*'''Pawn is single-threaded.''' As of this writing, Pawn is not thread safe. &lt;br /&gt;
*'''Pawn is compiled.''' Pawn is compiled to an intermediate, machine-independent code, which is stored in a &amp;quot;.smx&amp;quot; file. When loading .smx files, SourceMod translates this code to machine code for the platform and CPU it's running on.&lt;br /&gt;
&lt;br /&gt;
Early language design decisions were made by ITB CompuPhase. It is designed for low-level embedded devices and is thus very small and very fast.&lt;br /&gt;
&lt;br /&gt;
=Variables=&lt;br /&gt;
Pawn currently supports the following basic variable types:&lt;br /&gt;
*&amp;lt;tt&amp;gt;bool&amp;lt;/tt&amp;gt; - true or false.&lt;br /&gt;
*&amp;lt;tt&amp;gt;char&amp;lt;/tt&amp;gt; - an 8-bit ASCII character.&lt;br /&gt;
*&amp;lt;tt&amp;gt;int&amp;lt;/tt&amp;gt; - a 32-bit signed integer.&lt;br /&gt;
*&amp;lt;tt&amp;gt;float&amp;lt;/tt&amp;gt; - a 32-bit IEEE-754 floating point number.&lt;br /&gt;
*&amp;lt;tt&amp;gt;Handle&amp;lt;/tt&amp;gt; - the base type of a SourceMod object&lt;br /&gt;
&lt;br /&gt;
Other types may exist when defined in include files - for example, enums create new types for named integers, and many types derive from &amp;lt;tt&amp;gt;Handle&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Strings, currently, are 0-terminated arrays of &amp;lt;tt&amp;gt;char&amp;lt;/tt&amp;gt;s. They're described a little further ahead.&lt;br /&gt;
&lt;br /&gt;
==Declaration==&lt;br /&gt;
Below we include some examples of variable declarations, both valid and invalid. Keep in mind that SourcePawn has recently added new syntax, and that's what's documented below. Older code may use older declaration syntax, which is no longer supported.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
int a = 5;&lt;br /&gt;
float b = 5.0;&lt;br /&gt;
bool c = true;&lt;br /&gt;
bool d = false;&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Invalid variable usage:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
int a = 5.0;         // Type mismatch. 5.0 is a float.&lt;br /&gt;
float b = 5;         // Type mismatch. 5 is an integer.&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If a variable is not assigned upon declaration, it will be set to 0. For example:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
int a;        // Set to 0&lt;br /&gt;
float b;      // Set to 0.0&lt;br /&gt;
bool c;       // Set to false&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Assignment==&lt;br /&gt;
Variables can be re-assigned data after they are created. For example:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;int a;&lt;br /&gt;
float b;&lt;br /&gt;
bool c;&lt;br /&gt;
&lt;br /&gt;
a = 5;&lt;br /&gt;
b = 5.0;&lt;br /&gt;
c = true;&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Arrays=&lt;br /&gt;
An array is a sequence of data in a list. Arrays are useful for storing multiple pieces of data in one variable, or mapping one type of data to another.&lt;br /&gt;
&lt;br /&gt;
==Declaration==&lt;br /&gt;
An array is declared using brackets. Some examples of arrays:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
int players[32];     // Stores 32 integers.&lt;br /&gt;
float origin[3];     // Stores 3 floating point numbers&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By default, arrays are initialized to 0. You can assign them different default values, however:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
int numbers[5] = {1, 2, 3, 4, 5};       // Stores 1, 2, 3, 4, 5.&lt;br /&gt;
float origin[3] = {1.0, 2.0, 3.0};      // Stores 1.0, 2.0, 3.0.&lt;br /&gt;
int autoNum[3] = {1, ...};              // Stores 1, 1, 1&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can leave out the array size if you're going to pre-assign data to it. For example:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
int numbers[] = {1, 3, 5, 7, 9};&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The compiler will automatically deduce that you intended an array of size 5.&lt;br /&gt;
&lt;br /&gt;
When array is declared with brackets after its name, Pawn considers that array to have a '''fixed size'''. The size of a fixed-size array is always known. Some arrays can be '''dynamically sized''', by putting the brackets before the name. For example,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
int[] numbers = new int[MaxClients]&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This creates an array of size &amp;lt;tt&amp;gt;MaxClients&amp;lt;/tt&amp;gt;, which could be anything, so the size of the array is not known until the array is allocated.&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
Using an array is just like using a normal variable. The only difference is the array must be '''indexed'''. Indexing an array means choosing the element which you wish to use.&lt;br /&gt;
&lt;br /&gt;
For example, here is an example of the above code using indexes:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
int numbers[5];&lt;br /&gt;
float origin[3];&lt;br /&gt;
&lt;br /&gt;
numbers[0] = 1;&lt;br /&gt;
numbers[1] = 2;&lt;br /&gt;
numbers[2] = 3;&lt;br /&gt;
numbers[3] = 4;&lt;br /&gt;
numbers[4] = 5;&lt;br /&gt;
origin[0] = 1.0;&lt;br /&gt;
origin[1] = 2.0;&lt;br /&gt;
origin[2] = 3.0;&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the '''index''' is what's in between the brackets. The index always starts from 0. That is, if an array has N elements, its valid indexes are from 0 to N-1. Accessing the data at these indexes works like a normal variable.&lt;br /&gt;
&lt;br /&gt;
Using an incorrect index will cause an error. For example:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
int numbers[5];&lt;br /&gt;
&lt;br /&gt;
numbers[5] = 20;&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This may look correct, but 5 is not a valid index. The highest valid index is 4.&lt;br /&gt;
&lt;br /&gt;
You can use any expression as an index. For example:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;int a, numbers[5];&lt;br /&gt;
&lt;br /&gt;
a = 1;                   // Set a = 1&lt;br /&gt;
numbers[a] = 4;          // Set numbers[1] = 4&lt;br /&gt;
numbers[numbers[a]] = 2; // Set numbers[4] = 2&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Expressions will be discussed in depth later in the article.&lt;br /&gt;
&lt;br /&gt;
=Enums=&lt;br /&gt;
Enums are retyped integers.  A new enum can be declared as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;enum MyEnum // the name is optional&lt;br /&gt;
{&lt;br /&gt;
  MyFirstValue, // == 0, if not explicitly assigned, the first value is zero&lt;br /&gt;
  MySecondValue, // == 1, implicitly set to the previous value plus one&lt;br /&gt;
  MyThirdValue = 1, // == 1, explicitly assign to one -- multiple names can share the same value&lt;br /&gt;
  MyFourthValue, // == 2&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To allow implicit conversions of enums back to integers (that is, so functions expecting a value of type 'int' accepts it as one instead of generating a warning), the enum must either be anonymous (unnamed) or must start with a lowercase character.&lt;br /&gt;
&lt;br /&gt;
=Strings=&lt;br /&gt;
Strings are a construct for storing text (or even raw binary data). A string is just an array of characters, except that the final character must be 0 (called the null terminator). Without a null terminator, Pawn would not know where to stop reading the string. All strings are [http://en.wikipedia.org/wiki/UTF-8 UTF-8] in SourcePawn.&lt;br /&gt;
&lt;br /&gt;
In general, you must have an idea of how large a string will be before you store it. SourcePawn does not yet have the capability of pre-determining storage space for strings.&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
Strings are usually declared as arrays. For example:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
char message[] = &amp;quot;Hello!&amp;quot;;&lt;br /&gt;
char clams[6] = &amp;quot;Clams&amp;quot;;&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are equivalent to doing:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
char message[7];&lt;br /&gt;
char clams[6];&lt;br /&gt;
&lt;br /&gt;
message[0] = 'H';&lt;br /&gt;
message[1] = 'e';&lt;br /&gt;
message[2] = 'l';&lt;br /&gt;
message[3] = 'l';&lt;br /&gt;
message[4] = 'o';&lt;br /&gt;
message[5] = '!';&lt;br /&gt;
message[6] = 0;&lt;br /&gt;
clams[0] = 'C';&lt;br /&gt;
clams[1] = 'l';&lt;br /&gt;
clams[2] = 'a';&lt;br /&gt;
clams[3] = 'm';&lt;br /&gt;
clams[4] = 's';&lt;br /&gt;
clams[5] = 0;&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Although strings are rarely initialized in this manner, it is very important to remember the concept of the null terminator, which signals the end of a string. The compiler, and most SourceMod functions will automatically null-terminate for you, so it is mainly important when manipulating strings directly.&lt;br /&gt;
&lt;br /&gt;
Note that a string is enclosed in double-quotes, but a character is enclosed in single quotes.&lt;br /&gt;
&lt;br /&gt;
==Characters==&lt;br /&gt;
A character of text can be used in either a String or a cell. For example:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;char text[] = &amp;quot;Crab&amp;quot;;&lt;br /&gt;
char clam;&lt;br /&gt;
&lt;br /&gt;
clam = 'D';         //Set clam to 'D'&lt;br /&gt;
text[0] = 'A';      //Change the 'C' to 'A', it is now 'Arab'&lt;br /&gt;
clam = text[0];     //Set clam to 'A'&lt;br /&gt;
text[1] = clam;     //Change the 'r' to 'A', is is now 'AAab'&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What you can't do is mix character arrays with strings. The internal storage is different. For example:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
int clams[] = &amp;quot;Clams&amp;quot;;                       // Invalid.&lt;br /&gt;
int clams[] = {'C', 'l', 'a', 'm', 's', 0};  // Valid, but NOT A STRING.&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Concatenation==&lt;br /&gt;
In programming, concatenation is the operation of joining character strings end-to-end. The benefit of this is to improve the readability of the source code for humans, since the compiler will continue to treat the strings as a single string. String literals can be concatenated with the &amp;lt;tt&amp;gt;...&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;\&amp;lt;/tt&amp;gt; operator:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
char text[] = &amp;quot;This is a really long string of text that should be split over multiple lines for the sake of readability.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
char text[] = &amp;quot;This is a really long string of text that should be &amp;quot;&lt;br /&gt;
	... &amp;quot;split over multiple lines for the sake of readability.&amp;quot;; // Valid.&lt;br /&gt;
&lt;br /&gt;
char text[] = &amp;quot;This is a really long string of text that should be \&lt;br /&gt;
	split over multiple lines for the sake of readability.&amp;quot;; // Valid.&lt;br /&gt;
&lt;br /&gt;
char prefix[] = &amp;quot;What you can't do, however, &amp;quot;;&lt;br /&gt;
char moreText[] = prefix ... &amp;quot;is concatenate using a non-literal string.&amp;quot;; // Invalid, not a constant expression.&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Functions=&lt;br /&gt;
Functions, as stated before, are isolated blocks of code that perform an action. They can be invoked, or '''called''', with '''parameters''' that give specific options.&lt;br /&gt;
&lt;br /&gt;
There are two types of ways functions are called:&lt;br /&gt;
*'''direct call''' - You specifically call a function in your code.&lt;br /&gt;
*'''callback''' - The application calls a function in your code, as if it were an event trigger.&lt;br /&gt;
&lt;br /&gt;
There are six types of functions:&lt;br /&gt;
*'''native''': A direct, internal function provided by the application.&lt;br /&gt;
*'''public''': A callback function that is visible to the application and other scripts.&lt;br /&gt;
*'''normal''': A normal function that only you can call.&lt;br /&gt;
*'''static''': The scope of this function is restricted to the current file, can be used in combination with stock.&lt;br /&gt;
*'''stock''': A normal function provided by an include file. If unused, it won't be compiled.&lt;br /&gt;
*'''forward''': This function is a global event provided by the application. If you implement it, it will be a callback.&lt;br /&gt;
&lt;br /&gt;
All code in Pawn must exist in functions. This is in contrast to languages like PHP, Perl, and Python which let you write global code. That is because Pawn is a callback-based language: it responds to actions from a parent application, and functions must be written to handle those actions. Although our examples often contain free-floating code, this is purely for demonstration purposes. Free-floating code in our examples implies the code is part of some function.&lt;br /&gt;
&lt;br /&gt;
==Declaration==&lt;br /&gt;
Unlike variables, functions do not need to be declared before you use them. Functions have two pieces, the '''signature''' and the '''body'''. The signature contains the name of your function and the parameters it will accept. The body is the contents of its code.&lt;br /&gt;
&lt;br /&gt;
Example of a function:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
int AddTwoNumbers(int first, int second)&lt;br /&gt;
{&lt;br /&gt;
  int sum = first + second;&lt;br /&gt;
  return sum;&lt;br /&gt;
}&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a simple function. The prototype is this line:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;int AddTwoNumbers(int first, int second)&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Broken down, it means:&lt;br /&gt;
*&amp;lt;tt&amp;gt;int&amp;lt;/tt&amp;gt; - Return value type (integer).&lt;br /&gt;
*&amp;lt;tt&amp;gt;AddTwoNumbers&amp;lt;/tt&amp;gt; - Name of the function.&lt;br /&gt;
*&amp;lt;tt&amp;gt;int first&amp;lt;/tt&amp;gt; - First parameter, an integer.&lt;br /&gt;
*&amp;lt;tt&amp;gt;int second&amp;lt;/tt&amp;gt; - Second parameter, an integer.&lt;br /&gt;
&lt;br /&gt;
The body is a block of code. It creates a new variable, called &amp;lt;tt&amp;gt;sum&amp;lt;/tt&amp;gt;, and assigns it the value of the two parameters added together (more on expressions later). The important thing to notice is the &amp;lt;tt&amp;gt;return&amp;lt;/tt&amp;gt; statement, which tells the function to end and return a value to the caller of the function. All functions return something on completion, unless they return a special type called &amp;lt;tt&amp;gt;void&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
A function can accept any type of input, and it can return any non-array type.&lt;br /&gt;
&lt;br /&gt;
You can, of course, pass variables to functions:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;int numbers[3] = {1, 2, 0};&lt;br /&gt;
&lt;br /&gt;
numbers[2] = AddTwoNumbers(numbers[0], numbers[1]);&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that cells are passed '''by value'''. That is, their value cannot be changed by the function. For example:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;int a = 5;&lt;br /&gt;
&lt;br /&gt;
ChangeValue(a);&lt;br /&gt;
&lt;br /&gt;
void ChangeValue(int b)&lt;br /&gt;
{&lt;br /&gt;
   b = 5;&lt;br /&gt;
}&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This code would not change the value of &amp;lt;tt&amp;gt;a&amp;lt;/tt&amp;gt;. That is because a copy of the value in &amp;lt;tt&amp;gt;a&amp;lt;/tt&amp;gt; is passed instead of &amp;lt;tt&amp;gt;a&amp;lt;/tt&amp;gt; itself. &lt;br /&gt;
&lt;br /&gt;
More examples of functions will be provided throughout the article.&lt;br /&gt;
&lt;br /&gt;
==Publics==&lt;br /&gt;
Public functions are used to implement callbacks. You should not create a public function unless it is specifically implementing a callback. For example, here are two callbacks from &amp;lt;tt&amp;gt;sourcemod.inc&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;forward void OnPluginStart();&lt;br /&gt;
forward void OnClientDisconnected(int client);&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To implement and receive these two events, you would write functions as such:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;public void OnPluginStart()&lt;br /&gt;
{&lt;br /&gt;
   /* Code here */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public void OnClientDisconnected(int client)&lt;br /&gt;
{&lt;br /&gt;
   /* Code here */&lt;br /&gt;
}&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The '''public''' keyword signals to the parent application that it should attach the function to the appropriate forwarded event.&lt;br /&gt;
&lt;br /&gt;
==Natives==&lt;br /&gt;
Natives are builtin functions provided by SourceMod. You can call them as if they were a normal function. For example, SourceMod has the following function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;native float FloatRound(float num);&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It can be called like so:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;int rounded = FloatRound(5.2);     // rounded will be 5&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Array Parameters==&lt;br /&gt;
You can pass arrays or Strings as parameters. It is important to note that these are passed '''by reference'''. That is, rather than making a copy of the data, the data is referenced directly. There is a simple way of explaining this more concretely.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
int example[] = {1, 2, 3, 4, 5};&lt;br /&gt;
&lt;br /&gt;
ChangeArray(example, 2, 29);&lt;br /&gt;
&lt;br /&gt;
void ChangeArray(int[] array, int index, int value)&lt;br /&gt;
{&lt;br /&gt;
   array[index] = value;&lt;br /&gt;
}&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The function sets the given index in the array to a given value. When it is run on our example array, it changes index 2 to from the value 3 to 29. I.e.:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;example[2] = 29;&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note two important things here. First, arrays are not copied when they are passed to functions - they are passed ''by reference'', so the view of the array is consistent at all times. Second, the brackets changed position in our function signature. This is because our function accepts an array of any size, and since we don't know the size, we must use the dynamic array syntax.&lt;br /&gt;
&lt;br /&gt;
To prevent an array from being modified in a function, you can mark it as &amp;lt;tt&amp;gt;const&amp;lt;/tt&amp;gt;. This will raise an error on code that attempts to modify it. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;void CantChangeArray(const int[] array, int index, int value)&lt;br /&gt;
{&lt;br /&gt;
   array[index] = value;    //Won't compile&lt;br /&gt;
}&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is a good idea to use &amp;lt;tt&amp;gt;const&amp;lt;/tt&amp;gt; in array parameters if you know the array won't be modified; this can prevent coding mistakes.&lt;br /&gt;
&lt;br /&gt;
When a function takes an array as a parameter, you can also pass any indexed array element which will be interpreted as a sub-array (slice) that begins from that index. For example,&lt;br /&gt;
if you want to get the length of a string, you can use the strlen function like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
char myString[] = &amp;quot;myString&amp;quot;;&lt;br /&gt;
int length = strlen(myString); // Set length = 8&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And if you pass an indexed array element, it will be interpreted as a slice that begins from that index like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
char myString[] = &amp;quot;myString&amp;quot;;&lt;br /&gt;
int length = strlen(myString[2]); // Set length = 6&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Named Parameters==&lt;br /&gt;
With functions that have many parameters with default values, you can call the function with named parameters to assign a value based on its name instead of which position it is in the argument list.  For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
void SomeFunctionWithDefaultParams(int a, int b = 1, int c = 2, int d = 3, int e = 4);&lt;br /&gt;
&lt;br /&gt;
// If you want to call it with a different value for `d` -- note the dotted argument assignment&lt;br /&gt;
SomeFunctionWithDefaultParams(0, .d = 14);&lt;br /&gt;
&lt;br /&gt;
// This is effectively the same, but less readable:&lt;br /&gt;
SomeFunctionWithDefaultParams(0, _, _, 14, _);&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Expressions=&lt;br /&gt;
Expressions are exactly the same as they are in mathematics. They are groups of operators/symbols which evaluate to one piece of data. They are often parenthetical (comprised of parenthesis). They contain a strict &amp;quot;order of operations.&amp;quot;  They can contain variables, functions, numbers, and expressions themselves can be nested inside other expressions, or even passed as parameters.&lt;br /&gt;
&lt;br /&gt;
The simplest expression is a single number. For example:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
0;   //Returns the number 0&lt;br /&gt;
(0); //Returns the number 0 as well&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Although expressions can return any value, they are also said to either return ''zero or non-zero''. In that sense, ''zero'' is ''false'', and ''non-zero'' is ''true''. For example, -1 is '''true''' in Pawn, since it is non-zero. Do not assume negative numbers are false.&lt;br /&gt;
&lt;br /&gt;
The order of operations for expressions is similar to C. PMDAS: Parenthesis, Multiplication, Division, Addition, Subtraction. Here are some example expressions:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
5 + 6;                   //Evaluates to 11&lt;br /&gt;
5 * 6 + 3;               //Evaluates to 33&lt;br /&gt;
5 * (6 + 3);             //Evaluates to 45&lt;br /&gt;
5.0 + 2.3;               //Evaluates to 7.3&lt;br /&gt;
(5 * 6) % 7;             //Modulo operator, evaluates to 2&lt;br /&gt;
(5 + 3) / 2 * 4 - 9;     //Evaluates to -8&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As noted, expressions can contain variables, or even functions:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
int a = 5 * 6;&lt;br /&gt;
int b = a * 3;      //Evaluates to 90&lt;br /&gt;
int c = AddTwoNumbers(a, b) + (a * b);&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note:  String manipulation routines may be found in the string.inc file located in the include subdirectory. They may be browsed through the [http://docs.sourcemod.net/api/ API Reference] as well.&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
There are a few extra helpful operators in Pawn. The first set simplifies self-aggregation expressions. For example:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;int a = 5;&lt;br /&gt;
&lt;br /&gt;
a = a + 5;&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Can be rewritten as:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;int a = 5;&lt;br /&gt;
a += 5;&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is true of the following operators in Pawn:&lt;br /&gt;
*Four-function: *, /, -, +&lt;br /&gt;
*Bit-wise: |, &amp;amp;, ^, ~, &amp;lt;&amp;lt;, &amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Additionally, there are increment/decrement operators:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;a = a + 1;&lt;br /&gt;
a = a - 1;&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Can be simplified as:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;a++;&lt;br /&gt;
a--;&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As an advanced note, the ++ or -- can come before the variable (pre-increment, pre-decrement) or after the variable (post-increment, post-decrement). The difference is in how the rest of the expression containing them sees their result.&lt;br /&gt;
&lt;br /&gt;
* ''Pre:'' The variable is incremented before evaluation, and the rest of the expression sees the new value.&lt;br /&gt;
* ''Post:'' The variable is incremented after evaluation, and the rest of the expression sees the old value.&lt;br /&gt;
&lt;br /&gt;
In other words, &amp;lt;tt&amp;gt;a++&amp;lt;/tt&amp;gt; evaluates to the value of &amp;lt;tt&amp;gt;a&amp;lt;/tt&amp;gt; while &amp;lt;tt&amp;gt;++a&amp;lt;/tt&amp;gt; evaluates to the value of &amp;lt;tt&amp;gt;a + 1&amp;lt;/tt&amp;gt;. In both cases &amp;lt;tt&amp;gt;a&amp;lt;/tt&amp;gt; is incremented by &amp;lt;tt&amp;gt;1&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;int a = 5;&lt;br /&gt;
int b = a++;   // b = 5, a = 6  (1)&lt;br /&gt;
int c = ++a;   // a = 7, c = 7  (2)&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In (1) &amp;lt;tt&amp;gt;b&amp;lt;/tt&amp;gt; is assigned &amp;lt;tt&amp;gt;a&amp;lt;/tt&amp;gt;'s ''old'' value ''before'' it is incremented to &amp;lt;tt&amp;gt;6&amp;lt;/tt&amp;gt;, but in (2) &amp;lt;tt&amp;gt;c&amp;lt;/tt&amp;gt; is assigned &amp;lt;tt&amp;gt;a&amp;lt;/tt&amp;gt;'s ''int'' value ''after'' it is incremented to &amp;lt;tt&amp;gt;7&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Comparison Operators==&lt;br /&gt;
There are six operators for comparing two values numerically, and the result is either true (non-zero) or false (zero):&lt;br /&gt;
*&amp;lt;tt&amp;gt;a == b&amp;lt;/tt&amp;gt; - True if a and b have the same value.&lt;br /&gt;
*&amp;lt;tt&amp;gt;a != b&amp;lt;/tt&amp;gt; - True if a and b have different values.&lt;br /&gt;
*&amp;lt;tt&amp;gt;a &amp;amp;gt; b&amp;lt;/tt&amp;gt; - True if a is greater than b&lt;br /&gt;
*&amp;lt;tt&amp;gt;a &amp;amp;gt;= b&amp;lt;/tt&amp;gt; - True if a is greater than or equal to b&lt;br /&gt;
*&amp;lt;tt&amp;gt;a &amp;amp;lt; b&amp;lt;/tt&amp;gt; - True if a is less than b&lt;br /&gt;
*&amp;lt;tt&amp;gt;a &amp;amp;lt;= b&amp;lt;/tt&amp;gt; - True if a is less than or equal to b&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
(1 != 3);         //Evaluates to true because 1 is not equal to 3.&lt;br /&gt;
(3 + 3 == 6);     //Evaluates to true because 3+3 is 6.&lt;br /&gt;
(5 - 2 &amp;gt;= 4);     //Evaluates to false because 3 is less than 4.&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that these operators do not work on arrays or strings. That is, you cannot compare either using &amp;lt;tt&amp;gt;==&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Truth Operators==&lt;br /&gt;
These truth values can be combined using three boolean operators:&lt;br /&gt;
*&amp;lt;tt&amp;gt;a &amp;amp;&amp;amp; b&amp;lt;/tt&amp;gt; - True if both a and b are true. False if a or b (or both) is false.&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;2&amp;quot; cellspacing=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
! &amp;lt;tt&amp;gt;&amp;amp;&amp;amp;&amp;lt;/tt&amp;gt; !! 0 !! 1&lt;br /&gt;
|-&lt;br /&gt;
! 0&lt;br /&gt;
| 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
! 1&lt;br /&gt;
| 0 || 1&lt;br /&gt;
|}&lt;br /&gt;
*&amp;lt;tt&amp;gt;a || b&amp;lt;/tt&amp;gt; - True if a or b (or both) is true. False if both a and b are false.&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;2&amp;quot; cellspacing=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
! &amp;lt;tt&amp;gt;&amp;lt;nowiki&amp;gt;||&amp;lt;/nowiki&amp;gt;&amp;lt;/tt&amp;gt; !! 0 !! 1&lt;br /&gt;
|-&lt;br /&gt;
! 0&lt;br /&gt;
| 0 || 1&lt;br /&gt;
|-&lt;br /&gt;
! 1&lt;br /&gt;
| 1 || 1&lt;br /&gt;
|}&lt;br /&gt;
*&amp;lt;tt&amp;gt;!a&amp;lt;/tt&amp;gt; - True if a is false. False if a is true.&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;2&amp;quot; cellspacing=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
! &amp;lt;tt&amp;gt;!&amp;lt;/tt&amp;gt; !! 0 !! 1&lt;br /&gt;
|- &lt;br /&gt;
!&lt;br /&gt;
| 1 || 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
(1 || 0);         //Evaluates to true because the expression 1 is true&lt;br /&gt;
(1 &amp;amp;&amp;amp; 0);         //Evaluates to false because the expression 0 is false&lt;br /&gt;
(!1 || 0);        //Evaluates to false because !1 is false.&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Left/Right Values==&lt;br /&gt;
Two important concepts are left-hand and right-hand values, or l-values and r-values. An l-value is what appears on the left-hand side of a variable assignment, and an r-value is what appears on the right side of a variable assignment.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
int a = 5;&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example &amp;lt;tt&amp;gt;a&amp;lt;/tt&amp;gt; is an l-value and &amp;lt;tt&amp;gt;5&amp;lt;/tt&amp;gt; is an r-value.&lt;br /&gt;
&lt;br /&gt;
The rules:&lt;br /&gt;
*'''Expressions are never l-values'''.&lt;br /&gt;
*'''Variables are both l-values and r-values'''.&lt;br /&gt;
&lt;br /&gt;
=Conditionals=&lt;br /&gt;
Conditional statements let you only run code if a certain condition is matched.&lt;br /&gt;
&lt;br /&gt;
==If Statements==&lt;br /&gt;
If statements test one or more conditions. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
if (a == 5)&lt;br /&gt;
{&lt;br /&gt;
   /* Code that will run if the expression was true */&lt;br /&gt;
}&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
They can be extended to handle more cases as well:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
if (a == 5)&lt;br /&gt;
{&lt;br /&gt;
   /* Code */&lt;br /&gt;
}&lt;br /&gt;
else if (a == 6)&lt;br /&gt;
{&lt;br /&gt;
   /* Code  */&lt;br /&gt;
}&lt;br /&gt;
else if (a == 7)&lt;br /&gt;
{&lt;br /&gt;
   /* Code */&lt;br /&gt;
}&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also handle the case of no expression being matched. For example:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
if (a == 5)&lt;br /&gt;
{&lt;br /&gt;
   /* Code */&lt;br /&gt;
}&lt;br /&gt;
else&lt;br /&gt;
{&lt;br /&gt;
   /* Code that will run if no expressions were true */&lt;br /&gt;
}&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Switch Statements==&lt;br /&gt;
Switch statements are restricted if statements. They test one expression for a series of possible values. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
switch (a)&lt;br /&gt;
{&lt;br /&gt;
   case 5:&lt;br /&gt;
   {&lt;br /&gt;
      /* code */&lt;br /&gt;
   }&lt;br /&gt;
   case 6:&lt;br /&gt;
   {&lt;br /&gt;
      /* code */&lt;br /&gt;
   }&lt;br /&gt;
   case 7:&lt;br /&gt;
   {&lt;br /&gt;
      /* code */&lt;br /&gt;
   }&lt;br /&gt;
   case 8, 9, 10:&lt;br /&gt;
   {&lt;br /&gt;
      /* Code */&lt;br /&gt;
   }&lt;br /&gt;
   default:&lt;br /&gt;
   {&lt;br /&gt;
      /* will run if no case matched */&lt;br /&gt;
   }&lt;br /&gt;
}&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unlike some other languages, switches are not fall-through. That is, multiple cases will never be run. When a case matches its code is executed, and the switch is then immediately terminated.&lt;br /&gt;
&lt;br /&gt;
=Loops=&lt;br /&gt;
Loops allow you to conveniently repeat a block of code while a given condition remains true. &lt;br /&gt;
&lt;br /&gt;
==For Loops==&lt;br /&gt;
For loops are loops which have four parts:&lt;br /&gt;
*The '''initialization''' statement - run once before the first loop.&lt;br /&gt;
*The '''condition''' statement - checks whether the next loop should run, including the first one. The loop terminates when this expression evaluates to false.&lt;br /&gt;
*The '''iteration''' statement - run after each loop.&lt;br /&gt;
*The '''body''' block - run each time the '''condition''' statement evaluates to true.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
for ( /* initialization */ ; /* condition */ ; /* iteration */ )&lt;br /&gt;
{&lt;br /&gt;
   /* body */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A simple example is a function to sum an array:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
int array[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};&lt;br /&gt;
int sum = SumArray(array, 10);&lt;br /&gt;
&lt;br /&gt;
int SumArray(const int[] array, int count)&lt;br /&gt;
{&lt;br /&gt;
   int total;&lt;br /&gt;
&lt;br /&gt;
   for (int i = 0; i &amp;lt; count; i++)&lt;br /&gt;
   {&lt;br /&gt;
      total += array[i];&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   return total;&lt;br /&gt;
}&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Broken down:&lt;br /&gt;
*&amp;lt;tt&amp;gt;int i = 0&amp;lt;/tt&amp;gt; - Creates a new variable for the loop, sets it to 0.&lt;br /&gt;
*&amp;lt;tt&amp;gt;i &amp;lt; count&amp;lt;/tt&amp;gt; - Only runs the loop if &amp;lt;tt&amp;gt;i&amp;lt;/tt&amp;gt; is less than &amp;lt;tt&amp;gt;count&amp;lt;/tt&amp;gt;. This ensures that the loop stops reading at a certain point. In this case, we don't want to read invalid indexes in the array.&lt;br /&gt;
*&amp;lt;tt&amp;gt;i++&amp;lt;/tt&amp;gt; - Increments &amp;lt;tt&amp;gt;i&amp;lt;/tt&amp;gt; by one after each loop. This ensures that the loop doesn't run forever; eventually &amp;lt;tt&amp;gt;i&amp;lt;/tt&amp;gt; will become too big and the loop will end.&lt;br /&gt;
&lt;br /&gt;
Thus, the &amp;lt;tt&amp;gt;SumArray&amp;lt;/tt&amp;gt; function will loop through each valid index of the array, each time adding that value of the array into a sum. For loops are very common for processing arrays like this.&lt;br /&gt;
&lt;br /&gt;
==While Loops==&lt;br /&gt;
While loops are less common than for loops but are actually the simplest possible loop. They have only two parts:&lt;br /&gt;
*The '''condition''' statement - checked before each loop. The loop terminates when it evaluates to false.&lt;br /&gt;
*The '''body''' block - run each time through the loop.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
while ( /* condition */ )&lt;br /&gt;
{&lt;br /&gt;
   /* body */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As long as the condition expression remains true, the loop will continue. Every for loop can be rewritten as a while loop:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
/* initialization */&lt;br /&gt;
while ( /* condition */ )&lt;br /&gt;
{&lt;br /&gt;
   /* body */&lt;br /&gt;
   /* iteration */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is the previous for loop rewritten as a while loop:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
int SumArray(const int[] array, int count)&lt;br /&gt;
{&lt;br /&gt;
   int total, i;&lt;br /&gt;
&lt;br /&gt;
   while (i &amp;lt; count)&lt;br /&gt;
   {&lt;br /&gt;
      total += array[i];&lt;br /&gt;
      i++;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   return total;&lt;br /&gt;
}&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are also '''do...while''' loops which are even less common. These are the same as while loops except the condition check is AFTER each loop, rather than before. This means the loop is always run at least once. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
do&lt;br /&gt;
{&lt;br /&gt;
   /* body */&lt;br /&gt;
}&lt;br /&gt;
while ( /* condition */ );&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Loop Control==&lt;br /&gt;
There are two cases in which you want to selectively control a loop:&lt;br /&gt;
*'''skipping''' one iteration of the loop but continuing as normal, or;&lt;br /&gt;
*'''breaking''' the loop entirely before it's finished.&lt;br /&gt;
&lt;br /&gt;
Let's say you have a function which takes in an array and searches for a matching number. You want it to stop once the number is found:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * Returns the array index where the value is, or -1 if not found.&lt;br /&gt;
 */&lt;br /&gt;
int SearchInArray(const int[] array, int count, int value)&lt;br /&gt;
{&lt;br /&gt;
   int index = -1;&lt;br /&gt;
 &lt;br /&gt;
   for (int i = 0; i &amp;lt; count; i++)&lt;br /&gt;
   {&lt;br /&gt;
      if (array[i] == value)&lt;br /&gt;
      {&lt;br /&gt;
         index = i;&lt;br /&gt;
         break;&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   return index;&lt;br /&gt;
}&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Certainly, this function could simply &amp;lt;tt&amp;gt;return i&amp;lt;/tt&amp;gt; instead, but the example shows how &amp;lt;tt&amp;gt;break&amp;lt;/tt&amp;gt; will terminate the loop.&lt;br /&gt;
&lt;br /&gt;
Similarly, the &amp;lt;tt&amp;gt;continue&amp;lt;/tt&amp;gt; keyword skips an iteration of a loop. For example, let's say we wanted to sum all even numbers:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
int SumEvenNumbers(const int[] array, int count)&lt;br /&gt;
{&lt;br /&gt;
   int sum;&lt;br /&gt;
 &lt;br /&gt;
   for (int i = 0; i &amp;lt; count; i++)&lt;br /&gt;
   {&lt;br /&gt;
      /* If divisibility by 2 is 1, we know it's odd */&lt;br /&gt;
      if (array[i] % 2 == 1)&lt;br /&gt;
      {&lt;br /&gt;
         /* Skip the rest of this loop iteration */&lt;br /&gt;
         continue;&lt;br /&gt;
      }&lt;br /&gt;
      sum += array[i];&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   return sum;&lt;br /&gt;
}&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Scope=&lt;br /&gt;
Scope refers to the '''visibility''' of code. That is, code at one level may not be &amp;quot;visible&amp;quot; to code at another level. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
int A, B, C;&lt;br /&gt;
&lt;br /&gt;
void Function1()&lt;br /&gt;
{&lt;br /&gt;
   int B;&lt;br /&gt;
&lt;br /&gt;
   Function2();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Function2()&lt;br /&gt;
{&lt;br /&gt;
   int C;&lt;br /&gt;
}&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, &amp;lt;tt&amp;gt;A&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;B&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;C&amp;lt;/tt&amp;gt; exist at '''global scope'''. They can be seen by any function. However, the &amp;lt;tt&amp;gt;B&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;Function1&amp;lt;/tt&amp;gt; is not the same variable as the &amp;lt;tt&amp;gt;B&amp;lt;/tt&amp;gt; at the global level. Instead, it is at '''local scope''', and is thus a '''local variable'''.&lt;br /&gt;
&lt;br /&gt;
Similarly, &amp;lt;tt&amp;gt;Function1&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;Function2&amp;lt;/tt&amp;gt; know nothing about each other's variables.&lt;br /&gt;
&lt;br /&gt;
Not only is the variable private to &amp;lt;tt&amp;gt;Function1&amp;lt;/tt&amp;gt;, but it is re-created each time the function is invoked. Imagine this:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
void Function1()&lt;br /&gt;
{&lt;br /&gt;
   int B;&lt;br /&gt;
&lt;br /&gt;
   Function1();&lt;br /&gt;
}&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the above example, &amp;lt;tt&amp;gt;Function1&amp;lt;/tt&amp;gt; calls itself. Of course, this is infinite recursion (a bad thing), but the idea is that each time the function runs, there is a new copy of &amp;lt;tt&amp;gt;B&amp;lt;/tt&amp;gt;. When the function ends, &amp;lt;tt&amp;gt;B&amp;lt;/tt&amp;gt; is destroyed, and the value is lost.&lt;br /&gt;
&lt;br /&gt;
This property can be simplified by saying that a variable's scope is equal to the nesting level it is in. That is, a variable at global scope is visible globally to all functions. A variable at local scope is visible to all code blocks &amp;quot;beneath&amp;quot; its nesting level. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;void Function1()&lt;br /&gt;
{&lt;br /&gt;
   int A;&lt;br /&gt;
&lt;br /&gt;
   if (A)&lt;br /&gt;
   {&lt;br /&gt;
      A = 5;&lt;br /&gt;
   }&lt;br /&gt;
}&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above code is valid since A's scope extends throughout the function. The following code, however, is not valid:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
void Function1()&lt;br /&gt;
{&lt;br /&gt;
   int A;&lt;br /&gt;
&lt;br /&gt;
   if (A)&lt;br /&gt;
   {&lt;br /&gt;
      int B = 5;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   B = 5;&lt;br /&gt;
}&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice that &amp;lt;tt&amp;gt;B&amp;lt;/tt&amp;gt; is declared in a new code block. That means &amp;lt;tt&amp;gt;B&amp;lt;/tt&amp;gt; is only accessible to that code block (and all sub-blocks nested within). As soon as the code block terminates, &amp;lt;tt&amp;gt;B&amp;lt;/tt&amp;gt; is no longer valid.&lt;br /&gt;
&lt;br /&gt;
=Dynamic Arrays=&lt;br /&gt;
Dynamic arrays are arrays which don't have a hardcoded size. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;void Function1(int size)&lt;br /&gt;
{&lt;br /&gt;
   int[] array = new int[size];&lt;br /&gt;
 &lt;br /&gt;
   /* Code */&lt;br /&gt;
}&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Dynamic arrays can have any expression as their size as long as the expression evaluates to a number larger than 0. Like normal arrays, SourcePawn does not know the array size after it is created; you have to save it if you want it later.&lt;br /&gt;
&lt;br /&gt;
Dynamic arrays are only valid at the local scope level, since code cannot exist globally.&lt;br /&gt;
&lt;br /&gt;
=Extended Variable Declarations=&lt;br /&gt;
Variables can be declared in more ways than simply &amp;lt;tt&amp;gt;int float or char&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==static==&lt;br /&gt;
The &amp;lt;tt&amp;gt;static&amp;lt;/tt&amp;gt; keyword is available at global and local scope. It has different meanings in each.&lt;br /&gt;
&lt;br /&gt;
===Global static===&lt;br /&gt;
A global static variable can only be accessed from within the same file. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;//file1.inc&lt;br /&gt;
static float g_value1 = 0.15f;&lt;br /&gt;
&lt;br /&gt;
//file2.inc&lt;br /&gt;
static float g_value2 = 0.15f;&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If a plugin includes both of these files, it will not be able to use either &amp;lt;tt&amp;gt;g_value1&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;g_value2&amp;lt;/tt&amp;gt;. This is a simple information hiding mechanism, and is similar to declaring member variables as &amp;lt;tt&amp;gt;private&amp;lt;/tt&amp;gt; in languages like C++, Java, or C#.&lt;br /&gt;
&lt;br /&gt;
===Local static===&lt;br /&gt;
A local static variable is a global variable that is only visible from its local lexical scope. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
int MyFunction(int inc)&lt;br /&gt;
{&lt;br /&gt;
   static int counter = -1;&lt;br /&gt;
&lt;br /&gt;
   counter += inc;&lt;br /&gt;
&lt;br /&gt;
   return counter;&lt;br /&gt;
}&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, &amp;lt;tt&amp;gt;counter&amp;lt;/tt&amp;gt; is technically a global variable -- it is initialized once to -1 and is never initialized again. It does not exist on the stack. That means each time &amp;lt;tt&amp;gt;MyFunction&amp;lt;/tt&amp;gt; runs, the &amp;lt;tt&amp;gt;counter&amp;lt;/tt&amp;gt; variable and its storage in memory is the same.&lt;br /&gt;
&lt;br /&gt;
Take this example:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;MyFunction(5);&lt;br /&gt;
MyFunction(6);&lt;br /&gt;
MyFunction(10);&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, &amp;lt;tt&amp;gt;counter&amp;lt;/tt&amp;gt; will be &amp;lt;tt&amp;gt;-1 + 5 + 6 + 10&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;20&amp;lt;/tt&amp;gt;, because it persists beyond the frame of the function. Note this may pose problems for recursive functions: if your function may be recursive, then &amp;lt;tt&amp;gt;static&amp;lt;/tt&amp;gt; is usually not a good idea unless your code is re-entrant. &lt;br /&gt;
&lt;br /&gt;
The benefit of a local static variable is that you don't have to clutter your script with global variables. As long as the variable doesn't need to be read by another function, you can squirrel it inside the function and its persistence will be guaranteed.&lt;br /&gt;
&lt;br /&gt;
Note that statics can exist in any local scope:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
int MyFunction(int inc)&lt;br /&gt;
{&lt;br /&gt;
   if (inc &amp;gt; 0)&lt;br /&gt;
   {&lt;br /&gt;
      static int counter;&lt;br /&gt;
      return (counter += inc);&lt;br /&gt;
   }&lt;br /&gt;
   return -1;&lt;br /&gt;
}&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:SourceMod Scripting]]&lt;br /&gt;
&lt;br /&gt;
{{LanguageSwitch}}&lt;/div&gt;</summary>
		<author><name>Impact123</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.alliedmods.net/index.php?title=Scripting_FAQ_(SourceMod)&amp;diff=8701</id>
		<title>Scripting FAQ (SourceMod)</title>
		<link rel="alternate" type="text/html" href="https://wiki.alliedmods.net/index.php?title=Scripting_FAQ_(SourceMod)&amp;diff=8701"/>
		<updated>2012-09-22T03:19:00Z</updated>

		<summary type="html">&lt;p&gt;Impact123: /* How do I hook +commands, such as +zoom and +attack? */  Removed the == IN_ATTACK, this only confuses users&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Yak.gif]]&lt;br /&gt;
yak wuz heer&lt;br /&gt;
&lt;br /&gt;
=How do I learn SourcePawn?=&lt;br /&gt;
A good start is on the [[Introduction to SourcePawn]] page, which will teach you the SourcePawn language. Then go through the [[Introduction to SourceMod Plugins]], which will teach you how to write your first plug-in.&lt;br /&gt;
&lt;br /&gt;
=Where can I find all the SourcePawn functions and other information?=&lt;br /&gt;
All SourceMod plug-ins have this line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pawn&amp;gt;#include &amp;lt;sourcemod&amp;gt;&amp;lt;/pawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This line instructs the compiler to retrieve the file &amp;lt;tt&amp;gt;sourcemod.inc&amp;lt;/tt&amp;gt; from the &amp;lt;tt&amp;gt;sourcemod/scripting/include&amp;lt;/tt&amp;gt; folder. Every function, variable, and definition can be found in the &amp;lt;tt&amp;gt;.inc&amp;lt;/tt&amp;gt; files inside the &amp;lt;tt&amp;gt;sourcemod/scripting/include&amp;lt;/tt&amp;gt; folder.&lt;br /&gt;
&lt;br /&gt;
But searching through all those files can be quite tedious. Thankfully, the honourable [https://forums.alliedmods.net/member.php?u=9443 Nican] created an API reference viewable on the web, complete with searching and commenting: [http://docs.sourcemod.net/api/ http://docs.sourcemod.net/api/]&lt;br /&gt;
&lt;br /&gt;
Also, if you are in the SourceMod IRC channel ([irc://irc.gamesurge.net/sourcemod #sourcemod on GameSurge]), you can use the &amp;lt;tt&amp;gt;!api&amp;lt;/tt&amp;gt; command to search [https://forums.alliedmods.net/member.php?u=9443 Nican's] API reference:&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;theY4Kman&amp;gt; !api Netclass&lt;br /&gt;
&amp;lt;yakbot&amp;gt; theY4Kman: GetEntityNetClass(edict, String:clsname[], maxlength): Retrieves an entity's networkable serverclass name. This is not the same as the classname and is used for networkable state changes. (http://docs.sourcemod.net/api/index.php?fastload=show&amp;amp;id=66)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=How do I find the classname of an entity? (e.g., &amp;quot;&amp;lt;tt&amp;gt;weapon_knife&amp;lt;/tt&amp;gt;&amp;quot; or &amp;quot;&amp;lt;tt&amp;gt;prop_physics&amp;lt;/tt&amp;gt;&amp;quot;)=&lt;br /&gt;
The classname of an entity (not to be confused with a netclass such as &amp;lt;tt&amp;gt;CCSPlayer&amp;lt;/tt&amp;gt;) is a unique identifier. It's the most well known of entity names. To find it, use the function [http://docs.sourcemod.net/api/index.php?fastload=show&amp;amp;id=65 GetEdictClassname()]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pawn&amp;gt;decl String:classname[128];&lt;br /&gt;
GetEdictClassname(myentity, classname, sizeof(classname));&lt;br /&gt;
&lt;br /&gt;
PrintToServer(&amp;quot;myentity classname: %s&amp;quot;, classname);&lt;br /&gt;
// myentity classname: weapon_knife&amp;lt;/pawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=How do I block regular commands, such as &amp;lt;tt&amp;gt;kill&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;say&amp;lt;/tt&amp;gt;?=&lt;br /&gt;
As of version 1.3, the recommended way to hook and block commands is with [http://docs.sourcemod.net/api/index.php?fastload=show&amp;amp;id=949 AddCommandListener()]. Previously, using [http://docs.sourcemod.net/api/index.php?fastload=show&amp;amp;id=470 RegConsoleCmd()] with the command name was the only way to hook commands, but this creates a whole new command for the command dispatch to check every time any command is executed. [http://docs.sourcemod.net/api/index.php?fastload=show&amp;amp;id=949 AddCommandListener()] creates only a lightweight hook, processed only when the specific command is executed.&lt;br /&gt;
&lt;br /&gt;
Here's how to use it to block the &amp;lt;tt&amp;gt;say&amp;lt;/tt&amp;gt; command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pawn&amp;gt;public OnPluginStart()&lt;br /&gt;
{&lt;br /&gt;
    AddCommandListener(SayCallback, &amp;quot;say&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public Action:SayCallback(client, const String:command[], argc)&lt;br /&gt;
{&lt;br /&gt;
    Return Plugin_Handled;&lt;br /&gt;
}&amp;lt;/pawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=How do I hook +commands, such as &amp;lt;tt&amp;gt;+zoom&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;+attack&amp;lt;/tt&amp;gt;?=&lt;br /&gt;
Unlike regular commands, &amp;lt;tt&amp;gt;+commands&amp;lt;/tt&amp;gt; are handled on the client's computer, then sent to the server in a more compressed fashion. This means [http://docs.sourcemod.net/api/index.php?fastload=show&amp;amp;id=949 AddCommandListener()] cannot be used to hook &amp;lt;tt&amp;gt;+commands&amp;lt;/tt&amp;gt;. As of version 1.3, the recommended solution is to use the global forward [http://docs.sourcemod.net/api/index.php?fastload=show&amp;amp;id=937 OnPlayerRunCmd()]. This forward is fired every time a player uses a movement button. To detect or block a &amp;lt;tt&amp;gt;+command&amp;lt;/tt&amp;gt;, you'll first have to find out its proper &amp;lt;tt&amp;gt;IN_&amp;lt;/tt&amp;gt; constant (see &amp;lt;tt&amp;gt;[http://docs.sourcemod.net/api/index.php?fastload=file&amp;amp;id=47&amp;amp;file=&amp;amp; entity_prop_stocks.inc]&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Here's how to use it to block crouching when attacking:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pawn&amp;gt;public Action:OnPlayerRunCmd(client, &amp;amp;buttons, &amp;amp;impulse, Float:vel[3], Float:angles[3], &amp;amp;weapon)&lt;br /&gt;
{&lt;br /&gt;
    // Check if the player is attacking (+attack)&lt;br /&gt;
    if (buttons &amp;amp; IN_ATTACK)&lt;br /&gt;
    {&lt;br /&gt;
        // If so, block their crouching (+duck)&lt;br /&gt;
        buttons &amp;amp;= ~IN_DUCK;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // We must return Plugin_Continue to let the changes be processed.&lt;br /&gt;
    // Otherwise, we can return Plugin_Handled to block the commands&lt;br /&gt;
    return Plugin_Continue;&lt;br /&gt;
}&amp;lt;/pawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=How do I get rid of loose indentation warnings?=&lt;br /&gt;
&amp;lt;pre&amp;gt;myplugin.sp(#) : warning 217: loose indentation&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Loose indentation warnings arise when indentation in your code is inconsistent. This usually means using both tabs and spaces as indentation. However, it can also mean a different amount of spaces or tabs are being used. Therefore, to correct it, use just one type of indentation. Because different editors have different settings for the size of tab stops, it is recommended you use 4 spaces to indent.&lt;br /&gt;
&lt;br /&gt;
Good:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pawn&amp;gt;public OnPluginStart()&lt;br /&gt;
{&lt;br /&gt;
    new myvar = 5;&lt;br /&gt;
    if (myvar == (2 + 3))&lt;br /&gt;
        PrintToServer(&amp;quot;myvar is %d&amp;quot;, myvar);&lt;br /&gt;
}&amp;lt;/pawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Bad:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pawn&amp;gt;public OnPluginStart()&lt;br /&gt;
{&lt;br /&gt;
	new myvar = 5;&lt;br /&gt;
    if (myvar == (2 + 3))&lt;br /&gt;
		PrintToServer(&amp;quot;myvar is %d&amp;quot;, myvar);&lt;br /&gt;
}&amp;lt;/pawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=How do I get rid of tag mismatch warnings?=&lt;br /&gt;
Though every variable in SourcePawn is one cell (4 bytes), with the exception of strings, there are many different ways to interpret what's inside a cell. To signify a cell's contents, tags are used. The most common are &amp;lt;tt&amp;gt;_&amp;lt;/tt&amp;gt; (the default tag: a vanilla cell. This tag is implied when no other tag is specified.), &amp;lt;tt&amp;gt;Float&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bool&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;String&amp;lt;/tt&amp;gt;. See [Introduction to SourcePawn#Variables_2] for more information.&lt;br /&gt;
&lt;br /&gt;
Functions wear these tags on their parameters so you can tell what needs to be passed to the function:&lt;br /&gt;
&amp;lt;pawn&amp;gt;native SetEntPropFloat(entity, PropType:type, const String:prop[], Float:value);&amp;lt;/pawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This function calls for '''&amp;lt;tt&amp;gt;entity&amp;lt;/tt&amp;gt;''', a cell with the implied tag '''''&amp;lt;tt&amp;gt;_&amp;lt;/tt&amp;gt;'''''; '''&amp;lt;tt&amp;gt;type&amp;lt;/tt&amp;gt;''', with the developer-defined tag '''''&amp;lt;tt&amp;gt;PropType&amp;lt;/tt&amp;gt;'''''; '''&amp;lt;tt&amp;gt;prop&amp;lt;/tt&amp;gt;''', with the built-in tag '''''&amp;lt;tt&amp;gt;String&amp;lt;/tt&amp;gt;'''''; and '''&amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt;''', with the built-in tag '''''&amp;lt;tt&amp;gt;Float&amp;lt;/tt&amp;gt;'''''.&lt;br /&gt;
To call this function, then, you must pass values with the specified tags. For example:&lt;br /&gt;
&amp;lt;pawn&amp;gt;SetEntPropFloat(1234, Prop_Send, &amp;quot;m_fNumber&amp;quot;, 1.0);&amp;lt;/pawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This calls the function correctly: &amp;lt;tt&amp;gt;1234&amp;lt;/tt&amp;gt; is a regular cell ('''''&amp;lt;tt&amp;gt;_&amp;lt;/tt&amp;gt;'''''), &amp;lt;tt&amp;gt;Prop_Send&amp;lt;/tt&amp;gt; is a variable defined in the enum '''''&amp;lt;tt&amp;gt;PropType&amp;lt;/tt&amp;gt;''''' in [http://docs.sourcemod.net/api/index.php?fastload=file&amp;amp;id=4&amp;amp;file=&amp;amp; entity.inc], &amp;lt;tt&amp;gt;&amp;quot;m_fNumber&amp;quot;&amp;lt;/tt&amp;gt; is a '''''&amp;lt;tt&amp;gt;String&amp;lt;/tt&amp;gt;''''', and &amp;lt;tt&amp;gt;1.0&amp;lt;/tt&amp;gt; is a '''''&amp;lt;tt&amp;gt;Float&amp;lt;/tt&amp;gt;'''''. For a nonexample:&lt;br /&gt;
&amp;lt;pawn&amp;gt;SetEntPropFloat(1234.0, 1, &amp;quot;m_fNumber&amp;quot;, 1337);&amp;lt;/pawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is incorrect! &amp;lt;tt&amp;gt;1234.0&amp;lt;/tt&amp;gt; is a '''''&amp;lt;tt&amp;gt;Float&amp;lt;/tt&amp;gt;''''' that should be a regular cell ('''''&amp;lt;tt&amp;gt;_&amp;lt;/tt&amp;gt;'''''); &amp;lt;tt&amp;gt;1&amp;lt;/tt&amp;gt; is a regular cell ('''''&amp;lt;tt&amp;gt;_&amp;lt;/tt&amp;gt;''''') that should be a '''''&amp;lt;tt&amp;gt;PropType&amp;lt;/tt&amp;gt;'''''; and &amp;lt;tt&amp;gt;1337&amp;lt;/tt&amp;gt; is a regular cell ('''''&amp;lt;tt&amp;gt;_&amp;lt;/tt&amp;gt;''''') that should be a '''''&amp;lt;tt&amp;gt;Float&amp;lt;/tt&amp;gt;'''''. This call will generate a tag mismatch warning. To correct it, simply use a value with the correct tag. Most of the time, tags that are not built-in (such as '''''&amp;lt;tt&amp;gt;PropType&amp;lt;/tt&amp;gt;''''') can be found in the same file where a function uses them (you can find '''''&amp;lt;tt&amp;gt;PropType&amp;lt;/tt&amp;gt;''''' in [http://docs.sourcemod.net/api/index.php?fastload=file&amp;amp;id=4&amp;amp;file=&amp;amp; entity.inc]).&lt;br /&gt;
&lt;br /&gt;
=How do I add color to my messages?=&lt;br /&gt;
Though the actual colors will vary depending on the mod, you can add color to any chat message using the characters &amp;lt;tt&amp;gt;0x01&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;0x08&amp;lt;/tt&amp;gt;. For example:&lt;br /&gt;
&amp;lt;pawn&amp;gt;PrintToChatAll (&amp;quot;\x01 1 .. \x02 2 .. \x03 3 .. \x04 4 .. \x05 5 .. \x06 6 .. \x07 7 .. \x08 8&amp;quot;);&amp;lt;/pawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example output from Left 4 Dead:&lt;br /&gt;
&lt;br /&gt;
[[Image:Left_4_Dead_Colors.png]]&lt;br /&gt;
&lt;br /&gt;
With a little experimenting, you can learn the colors for a mod. However, the meaning behind the colors is generally as follows:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt style=&amp;quot;color: blue;&amp;quot;&amp;gt;0x01&amp;lt;/tt&amp;gt; = Normal color&lt;br /&gt;
* &amp;lt;tt style=&amp;quot;color: blue;&amp;quot;&amp;gt;0x02&amp;lt;/tt&amp;gt; = Use team color to the end of a player's name. When used, it can be the only color used, and it must be at the start of the message.&lt;br /&gt;
* &amp;lt;tt style=&amp;quot;color: blue;&amp;quot;&amp;gt;0x03&amp;lt;/tt&amp;gt; = Team color&lt;br /&gt;
* &amp;lt;tt style=&amp;quot;color: blue;&amp;quot;&amp;gt;0x04&amp;lt;/tt&amp;gt; = Location color&lt;br /&gt;
&lt;br /&gt;
This data comes from Counter-Strike: Source.&lt;br /&gt;
&lt;br /&gt;
Unfortunately, to use players' team colors, you must use UserMessages, because there is no way for the current SourceMod functions to know which team color to use. Here's an example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pawn&amp;gt;new Handle:hBf;&lt;br /&gt;
hBf = StartMessageOne(&amp;quot;SayText2&amp;quot;, player_to); // To send the message to all players, use StartMessageAll(&amp;quot;SayText2&amp;quot;);&lt;br /&gt;
if (hBf != INVALID_HANDLE)&lt;br /&gt;
{&lt;br /&gt;
    BfWriteByte(hBf, player_from); &lt;br /&gt;
    BfWriteByte(hBf, 0); &lt;br /&gt;
    BfWriteString(hBf, &amp;quot;&amp;lt;\x03player_from team color\x01&amp;gt; My message&amp;quot;);&lt;br /&gt;
    EndMessage();&lt;br /&gt;
}&amp;lt;/pawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;player_to&amp;lt;/tt&amp;gt; is the client index to send the message to (or use [http://docs.sourcemod.net/api/index.php?fastload=show&amp;amp;id=132&amp;amp; StartMessageAll()] instead of [http://docs.sourcemod.net/api/index.php?fastload=show&amp;amp;id=133&amp;amp; StartMessageOne()] to send the message to all players). &amp;lt;tt&amp;gt;player_from&amp;lt;/tt&amp;gt; is the client index of the player whose team color will be utilized in the message. The message will now look like this (assuming &amp;lt;tt&amp;gt;player_from&amp;lt;/tt&amp;gt; is on the RED team):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:#AA0&amp;quot;&amp;gt;&amp;amp;lt;&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color:#F00&amp;quot;&amp;gt;player_from team color&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color:#AA0&amp;quot;&amp;gt;&amp;amp;gt; My message&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There's another catch, however: this is only known to work in CS:S and TF2. For other mods, your mileage may vary.&lt;br /&gt;
&lt;br /&gt;
==Color Libraries==&lt;br /&gt;
There are a few libraries that can handle colors for you, so you don't have to muck with UserMessages:&lt;br /&gt;
&lt;br /&gt;
===exvel's Colors===&lt;br /&gt;
This is a simple include file, allowing easy control over chat coloring. You can grab it [http://forums.alliedmods.net/showthread.php?t=96831 on the forums].  Instead of hex codes, colors are denoted with tags, such as &amp;lt;span style=&amp;quot;color: #AA0;&amp;quot;&amp;gt;&amp;lt;tt&amp;gt;{default}&amp;lt;/tt&amp;gt;&amp;lt;/span&amp;gt;, &amp;lt;span style=&amp;quot;color: #0F0;&amp;quot;&amp;gt;&amp;lt;tt&amp;gt;{green}&amp;lt;/tt&amp;gt;&amp;lt;/span&amp;gt;, or &amp;lt;span style=&amp;quot;color: #00F;&amp;quot;&amp;gt;&amp;lt;tt&amp;gt;{blue}&amp;lt;/tt&amp;gt;&amp;lt;/span&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Here's some example usage. Note that this code assumes client 1 is in game and on the &amp;lt;span style=&amp;quot;color: #00F;&amp;quot;&amp;gt;BLU&amp;lt;/span&amp;gt; team:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pawn&amp;gt;#include &amp;lt;colors&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public OnPluginStart()&lt;br /&gt;
{&lt;br /&gt;
    CPrintToChatAll(&amp;quot;{green}Hello {red}World! {default}Test 1 concluded.&amp;quot;);&lt;br /&gt;
    &lt;br /&gt;
    new client_on_blu_team = 1;&lt;br /&gt;
    CPrintToChatAllEx(client_on_blu_team, &amp;quot;{teamcolor}BLU team {default}says {green}hi!&amp;quot;);&lt;br /&gt;
}&amp;lt;/pawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color: #0F0;&amp;quot;&amp;gt;Hello &amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color: #F00;&amp;quot;&amp;gt;World! &amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color: #AA0;&amp;quot;&amp;gt;Test 1 concluded.&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color: #00F;&amp;quot;&amp;gt;BLU team &amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color: #AA0;&amp;quot;&amp;gt;says &amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color: #0F0;&amp;quot;&amp;gt;hi!&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that to use a team color, there needs to be at least one player on that team. Otherwise, it will default to &amp;lt;span style=&amp;quot;color: #0F0;&amp;quot;&amp;gt;&amp;lt;tt&amp;gt;{green}&amp;lt;/tt&amp;gt;&amp;lt;/span&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===SMLib===&lt;br /&gt;
[http://forums.alliedmods.net/showthread.php?p=1398699 SMLib] is a huge collection of stock functions to keep plug-in developers from reinventing the wheel. It includes a [http://forums.alliedmods.net/showthread.php?p=1398702#post1398702 colors API] very similar to [[#exvel's Colors|exvel's]]. The benefits of SMLib are it supports shorthand color names, such as &amp;lt;span style=&amp;quot;color: #AA0;&amp;quot;&amp;gt;&amp;lt;tt&amp;gt;{N}&amp;lt;/tt&amp;gt;&amp;lt;/span&amp;gt; and &amp;lt;span style=&amp;quot;color: #0F0;&amp;quot;&amp;gt;&amp;lt;tt&amp;gt;{G}&amp;lt;/tt&amp;gt;&amp;lt;/span&amp;gt;, and all colors are supported in its &amp;lt;tt&amp;gt;Client_PrintToChat()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
Here's how to print the same thing as the above example with SMLib. Note that this code also assumes client 1 is in game and on the &amp;lt;span style=&amp;quot;color: #00F;&amp;quot;&amp;gt;BLU&amp;lt;/span&amp;gt; team:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pawn&amp;gt;#include &amp;lt;smlib&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public OnPluginStart()&lt;br /&gt;
{&lt;br /&gt;
    Client_PrintToChatAll(&amp;quot;{G}Hello {R}World! {N}Test 1 concluded.&amp;quot;);&lt;br /&gt;
    &lt;br /&gt;
    new client_on_blu_team = 1;&lt;br /&gt;
    Client_PrintToChatAll(client_on_blu_team, &amp;quot;{T}BLU team {N}says {G}hi!&amp;quot;);&lt;br /&gt;
}&amp;lt;/pawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color: #0F0;&amp;quot;&amp;gt;Hello &amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color: #F00;&amp;quot;&amp;gt;World! &amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color: #AA0;&amp;quot;&amp;gt;Test 1 concluded.&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color: #00F;&amp;quot;&amp;gt;BLU team &amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color: #AA0;&amp;quot;&amp;gt;says &amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color: #0F0;&amp;quot;&amp;gt;hi!&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Why do I get an &amp;quot;unknown symbol&amp;quot; error when using an SDKTools native?=&lt;br /&gt;
None of SourceMod's or SDKTools's functions are built into SourcePawn. Therefore, every time you use one of their functions, SourcePawn needs to know how to call the function. Normally, this is done using includes. Just like you would #include &amp;lt;sourcemod&amp;gt; to use SourceMod's functions, you need to:&lt;br /&gt;
&amp;lt;pawn&amp;gt;#include &amp;lt;sdktools&amp;gt;&amp;lt;/pawn&amp;gt;&lt;br /&gt;
to use an SDKTools native.&lt;br /&gt;
&lt;br /&gt;
=Why is Source telling me my command is an &amp;quot;Unknown command&amp;quot;?=&lt;br /&gt;
This is because you're not returning &amp;lt;tt&amp;gt;Plugin_Handled&amp;lt;/tt&amp;gt; in your callback. If you don't, SourceMod believes you didn't want the Source Engine to know the command was registered, and it handles it so.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pawn&amp;gt;public Action:MyCommand(client, args)&lt;br /&gt;
{&lt;br /&gt;
    // Do something...&lt;br /&gt;
    &lt;br /&gt;
    return Plugin_Handled;&lt;br /&gt;
}&amp;lt;/pawn&amp;gt;&lt;/div&gt;</summary>
		<author><name>Impact123</name></author>
		
	</entry>
</feed>