Changing Maximum Player Count: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (moved Maxplayers 16 Fix to Changing Maximum Player Count: I am in the process of generalizing this article to make it more relevant to more people.)
No edit summary
Line 1: Line 1:
'''NOTE:'''
By default, Source modifications have a hard-coded maximum player count per server. This can often be overcome using certain server plugins, but if you want to change things the proper way for your modification, you'll need to manipulate your mod's source code a bit.
As of February 5, 2008, this only applies to the HL2DM OB (Orange Box) source code.


----
=== Source 2007 (HL2MP) ===
* Open hl2mp_gameinterface.cpp and find the implementation of the following function:


'''Problem: '''
* You are unable to create a server with more than 16 players.


'''Cause: '''
<source lang=cpp>void CServerGameClients::GetPlayerLimits( int& minplayers, int& maxplayers, int &defaultMaxPlayers )</source>
* For whatever reason, Valve decided to limit the maximum amount of players to 16 by altering the way maxplayers works. Fortunately, this is easy to fix.


'''Solution: '''
* Open hl2mp_gameinterface.cpp and make the following changes:


You'll see an integer called "maxplayers", which has a default value of '16'. Change the '16' to whatever you'd like, but going higher than 32 is not recommended, and obviously don't go below whatever is defined for "minplayers". You can also change "defaultMaxPlayers" here if you'd like.


REPLACE THIS:
=== Alien Swarm ===
<pre>void CServerGameClients::GetPlayerLimits( int& minplayers, int& maxplayers, int &defaultMaxPlayers ) const
[http://forums.steampowered.com/forums/showthread.php?t=1431604 Click here to be redirected to a topic about this on the Steam forums.]
{
minplayers = defaultMaxPlayers = 2;
maxplayers = 16;
}</pre>
 
WITH THIS:
<pre>void CServerGameClients::GetPlayerLimits( int& minplayers, int& maxplayers, int &defaultMaxPlayers ) const
{
minplayers = defaultMaxPlayers = 2;
maxplayers = 32;
}</pre>
 
Now you can have up to 32 players on your server at any given time instead of 16. Please do not try to set maxplayers to a value higher than 32. It's experimental, and after exceeding 32 players, a server would begin to become unstable.


[[Category:Programming]]
[[Category:Programming]]

Revision as of 08:24, 14 July 2011

By default, Source modifications have a hard-coded maximum player count per server. This can often be overcome using certain server plugins, but if you want to change things the proper way for your modification, you'll need to manipulate your mod's source code a bit.

Source 2007 (HL2MP)

  • Open hl2mp_gameinterface.cpp and find the implementation of the following function:


void CServerGameClients::GetPlayerLimits( int& minplayers, int& maxplayers, int &defaultMaxPlayers )


You'll see an integer called "maxplayers", which has a default value of '16'. Change the '16' to whatever you'd like, but going higher than 32 is not recommended, and obviously don't go below whatever is defined for "minplayers". You can also change "defaultMaxPlayers" here if you'd like.

Alien Swarm

Click here to be redirected to a topic about this on the Steam forums.