<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alliedmods.net/index.php?action=history&amp;feed=atom&amp;title=Clients_%28SourceMod_Scripting%29</id>
	<title>Clients (SourceMod Scripting) - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alliedmods.net/index.php?action=history&amp;feed=atom&amp;title=Clients_%28SourceMod_Scripting%29"/>
	<link rel="alternate" type="text/html" href="https://wiki.alliedmods.net/index.php?title=Clients_(SourceMod_Scripting)&amp;action=history"/>
	<updated>2026-07-09T19:10:45Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.6</generator>
	<entry>
		<id>https://wiki.alliedmods.net/index.php?title=Clients_(SourceMod_Scripting)&amp;diff=11830&amp;oldid=prev</id>
		<title>Nosoop: Update documentation to reflect changes in MAXPLAYERS definition</title>
		<link rel="alternate" type="text/html" href="https://wiki.alliedmods.net/index.php?title=Clients_(SourceMod_Scripting)&amp;diff=11830&amp;oldid=prev"/>
		<updated>2025-06-02T14:00:44Z</updated>

		<summary type="html">&lt;p&gt;Update documentation to reflect changes in MAXPLAYERS definition&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 14:00, 2 June 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l8&quot; &gt;Line 8:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 8:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;** This is set at runtime based on &amp;lt;tt&amp;gt;gpGlobals-&amp;gt;maxClients&amp;lt;/tt&amp;gt; in the game server.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;** This is set at runtime based on &amp;lt;tt&amp;gt;gpGlobals-&amp;gt;maxClients&amp;lt;/tt&amp;gt; in the game server.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &amp;lt;tt&amp;gt;MAXPLAYERS&amp;lt;/tt&amp;gt;: The theoretical maximum number of clients allowed on any Source game.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &amp;lt;tt&amp;gt;MAXPLAYERS&amp;lt;/tt&amp;gt;: The theoretical maximum number of clients allowed on any Source game.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;** &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;This &lt;/del&gt;number is set to &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;65&lt;/del&gt;, enough for &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;64 &lt;/del&gt;players + a SourceTV client.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;** &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;As of SourceMod 1.12 this &lt;/ins&gt;number is set to &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;101 for Team Fortress 2&lt;/ins&gt;, enough for &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;100 &lt;/ins&gt;players + a SourceTV client.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;These values represent the '''maximum count of clients'''. Since Client indexing starts at 1, be wary of off-by-one errors here!&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;These values represent the '''maximum count of clients'''. Since Client indexing starts at 1, be wary of off-by-one errors here!&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Nosoop</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.alliedmods.net/index.php?title=Clients_(SourceMod_Scripting)&amp;diff=11118&amp;oldid=prev</id>
		<title>ProdigySim: Created page with &quot;SourceMod assigns a Client Index number to client in the server. You can use these numbers to refer to specific clients in various SourceMod APIs. In particular, the [Clie...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.alliedmods.net/index.php?title=Clients_(SourceMod_Scripting)&amp;diff=11118&amp;oldid=prev"/>
		<updated>2020-10-16T19:50:24Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&lt;a href=&quot;/SourceMod&quot; title=&quot;SourceMod&quot;&gt;SourceMod&lt;/a&gt; assigns a Client Index number to client in the server. You can use these numbers to refer to specific clients in various SourceMod APIs. In particular, the [Clie...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[SourceMod]] assigns a Client Index number to client in the server. You can use these numbers to refer to specific clients in various SourceMod APIs. In particular, the [Clients APIs https://sm.alliedmods.net/new-api/clients].&lt;br /&gt;
&lt;br /&gt;
The server is given client index 0, and the first connected user will have client index 1.&lt;br /&gt;
&lt;br /&gt;
There are two variables that can be used to talk about the maximum number of clients:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;MaxClients&amp;lt;/tt&amp;gt;: The maximum number of players currently allowed to connect to the server.&lt;br /&gt;
** This is set at runtime based on &amp;lt;tt&amp;gt;gpGlobals-&amp;gt;maxClients&amp;lt;/tt&amp;gt; in the game server.&lt;br /&gt;
* &amp;lt;tt&amp;gt;MAXPLAYERS&amp;lt;/tt&amp;gt;: The theoretical maximum number of clients allowed on any Source game.&lt;br /&gt;
** This number is set to 65, enough for 64 players + a SourceTV client.&lt;br /&gt;
&lt;br /&gt;
These values represent the '''maximum count of clients'''. Since Client indexing starts at 1, be wary of off-by-one errors here!&lt;br /&gt;
&lt;br /&gt;
It's recommended that you use &amp;lt;tt&amp;gt;&amp;amp;lt;= MaxClients&amp;lt;/tt&amp;gt; when looping through the client list, and &amp;lt;tt&amp;gt;MAXPLAYERS+1&amp;lt;/tt&amp;gt; when initializing an array to contain data for individual clients.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;sourcepawn&amp;gt;&lt;br /&gt;
// Declare static arrays to support the maximum number of clients possible.&lt;br /&gt;
new playerVotes[MAXPLAYERS+1];&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
public void OnPluginStart()&lt;br /&gt;
{&lt;br /&gt;
    RegConsoleCmd(&amp;quot;start_vote&amp;quot;, Command_StartVote);&lt;br /&gt;
    RegConsoleCmd(&amp;quot;vote&amp;quot;, Command_Vote);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public Action Command_StartVote(int client, int args)&lt;br /&gt;
{&lt;br /&gt;
  // Loop through all clients based on current number of max clients.&lt;br /&gt;
  for(int i = 0; i &amp;lt;= MaxClients; i++) {&lt;br /&gt;
    playerVotes[i] = 0;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public Action Command_Vote(int client, int args)&lt;br /&gt;
{&lt;br /&gt;
    char arg[128];&lt;br /&gt;
    if( args &amp;gt; 0)&lt;br /&gt;
    {&lt;br /&gt;
        GetCmdArg(i, arg, sizeof(arg));&lt;br /&gt;
        // Associate data with clients at their client index in an array.&lt;br /&gt;
        playerVotes[client] = StringToInt(arg);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    return Plugin_Handled;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/sourcepawn&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Other notes:&lt;br /&gt;
&lt;br /&gt;
The game engine's CBaseServer has its own &amp;lt;tt&amp;gt;m_clients&amp;lt;/tt&amp;gt; list. You can subtract 1 from a SourceMod client index to get the &amp;lt;tt&amp;gt;CBaseServer::m_clients&amp;lt;/tt&amp;gt; index.&lt;/div&gt;</summary>
		<author><name>ProdigySim</name></author>
		
	</entry>
</feed>