http://www.gneu.org/wiki/index.php?title=HL2:_Creating_Teams

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<meta name="keywords" content="HL2: Creating Teams,Wildfire" />
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="search" type="application/opensearchdescription+xml" href="/wiki/opensearch_desc.php" title="Gneu.org (English)" />
<link title="Creative Commons" type="application/rdf+xml" href="/wiki/index.php?title=HL2:_Creating_Teams&amp;action=creativecommons" rel="meta" />
<link rel="copyright" href="http://www.gnu.org/copyleft/fdl.html" />
		<title>HL2: Creating Teams - Gneu.org</title>
		<style type="text/css" media="screen,projection">/*<![CDATA[*/ @import "/wiki/skins/monobook/main.css?42b"; /*]]>*/</style>
		<link rel="stylesheet" type="text/css" media="print" href="/wiki/skins/common/commonPrint.css?42b" />
		<link rel="stylesheet" type="text/css" media="handheld" href="/wiki/skins/monobook/handheld.css?42b" />
		<!--[if lt IE 5.5000]><style type="text/css">@import "/wiki/skins/monobook/IE50Fixes.css?42b";</style><![endif]-->
		<!--[if IE 5.5000]><style type="text/css">@import "/wiki/skins/monobook/IE55Fixes.css?42b";</style><![endif]-->
		<!--[if IE 6]><style type="text/css">@import "/wiki/skins/monobook/IE60Fixes.css?42b";</style><![endif]-->
		<!--[if IE 7]><style type="text/css">@import "/wiki/skins/monobook/IE70Fixes.css?42b";</style><![endif]-->
		<!--[if lt IE 7]><script type="text/javascript" src="/wiki/skins/common/IEFixes.js?42b"></script>
		<meta http-equiv="imagetoolbar" content="no" /><![endif]-->
		
		<script type= "text/javascript">/*<![CDATA[*/
var skin = "monobook";
var stylepath = "/wiki/skins";
var wgArticlePath = "/wiki/index.php?title=$1";
var wgScriptPath = "/wiki";
var wgServer = "http://www.gneu.org";
var wgCanonicalNamespace = "";
var wgCanonicalSpecialPageName = false;
var wgNamespaceNumber = 0;
var wgPageName = "HL2:_Creating_Teams";
var wgTitle = "HL2: Creating Teams";
var wgArticleId = "1502";
var wgIsArticle = true;
var wgUserName = null;
var wgUserLanguage = "en";
var wgContentLanguage = "en";
var wgBreakFrames = false;
var wgCurRevisionId = "1940";
/*]]>*/</script>
                
		<script type="text/javascript" src="/wiki/skins/common/wikibits.js?42b"><!-- wikibits js --></script>
		<script type="text/javascript" src="/wiki/index.php?title=-&amp;action=raw&amp;gen=js"><!-- site js --></script>
		<style type="text/css">/*<![CDATA[*/
@import "/wiki/index.php?title=MediaWiki:Common.css&usemsgcache=yes&action=raw&ctype=text/css&smaxage=18000";
@import "/wiki/index.php?title=MediaWiki:Monobook.css&usemsgcache=yes&action=raw&ctype=text/css&smaxage=18000";
@import "/wiki/index.php?title=-&action=raw&gen=css&maxage=18000";
/*]]>*/</style>
		<!-- Head Scripts -->
			</head>
<body  class="mediawiki ns-0 ltr page-HL2_Creating_Teams">
	<div id="globalWrapper">
		<div id="column-content">
	<div id="content">
		<a name="top" id="top"></a>
				<h1 class="firstHeading">HL2: Creating Teams</h1>
		<div id="bodyContent">
			<h3 id="siteSub">From Gneu.org</h3>
			<div id="contentSub"></div>
									<div id="jump-to-nav">Jump to: <a href="#column-one">navigation</a>, <a href="#searchInput">search</a></div>			<!-- start content -->
			<p><br />
This tutorial will lay out how to force teamplay in a <b>Deathmatch Source SDK</b>. If you want to set up teams for a from-scratch SDK, refer to <a href="http://articles.thewavelength.net/667/" class="external text" title="http://articles.thewavelength.net/667/" rel="nofollow">this</a> tutorial.
</p><p>First we will create a team menu, similar to the one seen in Counter-Strike: Source, then we will force HL2MP to be teamplay only.
</p><p><br />
</p>
<table id="toc" class="toc" summary="Contents"><tr><td><div id="toctitle"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1"><a href="#VGUI_Overview"><span class="tocnumber">1</span> <span class="toctext">VGUI Overview</span></a></li>
<li class="toclevel-1"><a href="#Team_Panel_and_Menu"><span class="tocnumber">2</span> <span class="toctext">Team Panel and Menu</span></a></li>
<li class="toclevel-1"><a href="#Menu_Layout"><span class="tocnumber">3</span> <span class="toctext">Menu Layout</span></a></li>
<li class="toclevel-1"><a href="#Menu_Command"><span class="tocnumber">4</span> <span class="toctext">Menu Command</span></a></li>
<li class="toclevel-1"><a href="#Localization"><span class="tocnumber">5</span> <span class="toctext">Localization</span></a></li>
<li class="toclevel-1"><a href="#Forcing_Teamplay"><span class="tocnumber">6</span> <span class="toctext">Forcing Teamplay</span></a></li>
<li class="toclevel-1"><a href="#Final_Touches"><span class="tocnumber">7</span> <span class="toctext">Final Touches</span></a></li>
</ul>
</td></tr></table><script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script>
<a name="VGUI_Overview"></a><h2><span class="editsection">[<a href="/wiki/index.php?title=HL2:_Creating_Teams&amp;action=edit&amp;section=1" title="Edit section: VGUI Overview">edit</a>]</span> <span class="mw-headline">VGUI Overview</span></h2>
<p>Before you start working on the VGUI team menu, it is recommended that you look at the VGUI2 Overview. (<a href="http://www.valve-erc.com/srcsdk/VGUI2/vgui2.html" class="external free" title="http://www.valve-erc.com/srcsdk/VGUI2/vgui2.html" rel="nofollow">http://www.valve-erc.com/srcsdk/VGUI2/vgui2.html</a>). You will learn that the base for all VGUI panels (not class-based, but where VGUI-objects are attached) is a viewport. This viewport is created in <b>cl_dll/sdk/clientmode_sdk.cpp</b> in the method <b>ClientModeSDKNormal::InitViewport</b>: 
</p>
<pre>void ClientModeSDKNormal::InitViewport()
{
  m_pViewport = new SDKViewport();
  m_pViewport-&gt;Start( gameuifuncs, gameeventmanager );
}</pre>
<p>This is just for reference. You do not need to edit anything here.
</p><p><br />
</p>
<a name="Team_Panel_and_Menu"></a><h2><span class="editsection">[<a href="/wiki/index.php?title=HL2:_Creating_Teams&amp;action=edit&amp;section=2" title="Edit section: Team Panel and Menu">edit</a>]</span> <span class="mw-headline">Team Panel and Menu</span></h2>
<p>Let's take a look at the CBaseViewport, which handles all the different Panels used by the mod. It is defined in <b>cl_dll/baseviewport.cpp</b>. 
</p><p>This function creates all panels known to this viewport: 
</p>
<pre>void CBaseViewport::CreateDefaultPanels( void )
{
  AddNewPanel( CreatePanelByName( PANEL_SCOREBOARD ) );
  AddNewPanel( CreatePanelByName( PANEL_INFO ) );
  AddNewPanel( CreatePanelByName( PANEL_SPECGUI ) );
  AddNewPanel( CreatePanelByName( PANEL_SPECMENU ) );
  // AddNewPanel( CreatePanelByName( PANEL_TEAM ) );
  // AddNewPanel( CreatePanelByName( PANEL_CLASS ) );
  // AddNewPanel( CreatePanelByName( PANEL_BUY ) );
}</pre>
<p>Since you want to enable the team menu, <b>uncomment</b> 
</p>
<pre>AddNewPanel( CreatePanelByName( PANEL_TEAM ) ); 
</pre>
<p>The "real" creation is done in the function <b>CBaseViewport::CreatePanelByName</b>, which takes the panelname as string and creates a corresponding class. The panel names are referenced in game_shared/viewport_panel_names.h, e.g. 
</p>
<pre>#define PANEL_TEAM "team" 
</pre>
<p><b>PANEL_TEAM</b> creates the class <b>CTeamMenu</b>, which contains all the functionality of that panel and is implemented in <b>game_controls/teammenu.cpp</b>. So uncomment that, too. 
</p>
<pre>  else if ( Q_strcmp(PANEL_TEAM, szPanelName) == 0 )
  {
    newpanel = new CTeamMenu( this );
  }</pre>
<p><br />
The class CTeamMenu is nearly functional; the only thing missing is the function which handles the messages created by the panel. Open <b>game_controls/teammenu.h</b> to add the declaration of the new function OnCommand to the class. Find 
</p>
<pre>// command callbacks 
</pre>
<p>and below it add 
</p>
<pre>virtual void OnCommand( const char *command );
</pre>
<p>Then add the implementation in <b>game_controls/teammenu.cpp</b>: 
</p>
<pre>void CTeamMenu::OnCommand( const char *command )
{
	if ( Q_stricmp( command, &quot;vguicancel&quot; ) )
	{
		engine-&gt;ClientCmd( const_cast&lt;char *&gt;( command ) );
	}
	Close();
	gViewPortInterface-&gt;ShowBackGround( false );
	BaseClass::OnCommand(command);
}</pre>
<p>You don't see anything done here with the commands. They are passed to the baseclass where hopefully they will be employed in a useful manner, but that is beyond the scope of this tutorial. 
</p><p><br />
</p>
<a name="Menu_Layout"></a><h2><span class="editsection">[<a href="/wiki/index.php?title=HL2:_Creating_Teams&amp;action=edit&amp;section=3" title="Edit section: Menu Layout">edit</a>]</span> <span class="mw-headline">Menu Layout</span></h2>
<p>The layout and contents of your panel can be defined solely by a resource file. If you don't need to do customized things (e.g. displaying gamemode-dependent buttons or map information), you won't require any more to complete your menu. 
</p><p>Most resources are missing in the Source SDK; the team menu resource is no exception. You need to create one yourself (or copy one from a cache file); the standard path would be <b>&lt;modname&gt;/resource/ui/Teammenu.res</b>. I think the format is self-explanatory, and you'll find an example below.
</p><p>It defines one panel (team), one label (joinTeam) and five buttons (jointeam1, jointeam2, jointeam3, autojoin, CancelButton). The interesting part in the button-definition is "Command", because this defines, which command the client executes, if he presses that button. 
</p><p>You don't need to edit the file by hand. Valve included a nice tool with which you may change it ingame, as mentioned in VGUI2 Overview (<a href="http://www.valve-erc.com/srcsdk/VGUI2/vgui2.html" class="external free" title="http://www.valve-erc.com/srcsdk/VGUI2/vgui2.html" rel="nofollow">http://www.valve-erc.com/srcsdk/VGUI2/vgui2.html</a>). Just press [SHIFT]+[CTRL]+[ALT]+[B] in the game to open the VGUI Build-Mode editor:
</p><p>Added: replaced example with modified Counter-Strike: Source team menu, which includes HTML map info panel. You can save this example into &lt;modname&gt;/resource/ui/TeamMenu.res:
</p>
<pre>&quot;Resource/UI/TeamMenu.res&quot;
{
	&quot;team&quot;
	{
		&quot;ControlName&quot;		&quot;CTeamMenu&quot;
		&quot;fieldName&quot;		&quot;team&quot;
		&quot;xpos&quot;			&quot;0&quot;
		&quot;ypos&quot;			&quot;0&quot;
		&quot;wide&quot;			&quot;640&quot;
		&quot;tall&quot;			&quot;480&quot;
		&quot;autoResize&quot;		&quot;0&quot;
		&quot;pinCorner&quot;		&quot;0&quot;
		&quot;visible&quot;		&quot;1&quot;
		&quot;enabled&quot;		&quot;1&quot;
		&quot;tabPosition&quot;		&quot;0&quot;
	}
	&quot;SysMenu&quot;
	{
		&quot;ControlName&quot;		&quot;Menu&quot;
		&quot;fieldName&quot;		&quot;SysMenu&quot;
		&quot;xpos&quot;			&quot;0&quot;
		&quot;ypos&quot;			&quot;0&quot;
		&quot;wide&quot;			&quot;64&quot;
		&quot;tall&quot;			&quot;24&quot;
		&quot;autoResize&quot;		&quot;0&quot;
		&quot;pinCorner&quot;		&quot;0&quot;
		&quot;visible&quot;		&quot;0&quot;
		&quot;enabled&quot;		&quot;0&quot;
		&quot;tabPosition&quot;		&quot;0&quot;
	}
	&quot;MapInfoHTML&quot;
	{
		&quot;ControlName&quot;		&quot;HTML&quot;
		&quot;fieldName&quot;			&quot;MapInfoHTML&quot;
		&quot;xpos&quot;				&quot;244&quot;
		&quot;ypos&quot;				&quot;116&quot;
		&quot;wide&quot;				&quot;316&quot;
		&quot;tall&quot;				&quot;286&quot;
		&quot;autoResize&quot;		&quot;0&quot;
		&quot;pinCorner&quot;			&quot;0&quot;
		&quot;visible&quot;			&quot;1&quot;
		&quot;enabled&quot;			&quot;1&quot;
		&quot;tabPosition&quot;		&quot;0&quot;
	}
	&quot;joinTeam&quot;
	{
		&quot;ControlName&quot;		&quot;Label&quot;
		&quot;fieldName&quot;		&quot;joinTeam&quot;
		&quot;xpos&quot;		&quot;76&quot;
		&quot;ypos&quot;		&quot;22&quot;
		&quot;wide&quot;		&quot;450&quot;
		&quot;tall&quot;		&quot;48&quot;
		&quot;autoResize&quot;		&quot;0&quot;
		&quot;pinCorner&quot;		&quot;0&quot;
		&quot;visible&quot;		&quot;1&quot;
		&quot;enabled&quot;		&quot;1&quot;
		&quot;labelText&quot;		&quot;#TM_Join_Team&quot;
		&quot;textAlignment&quot;		&quot;west&quot;
		&quot;dulltext&quot;		&quot;0&quot;
		&quot;brighttext&quot;	&quot;0&quot;
		&quot;font&quot;		&quot;MenuTitle&quot;
	}
	&quot;mapname&quot;
	{
		&quot;ControlName&quot;		&quot;Label&quot;
		&quot;fieldName&quot;		&quot;mapname&quot;
		&quot;xpos&quot;			&quot;244&quot;
		&quot;ypos&quot;			&quot;72&quot;
		&quot;wide&quot;			&quot;180&quot;
		&quot;tall&quot;			&quot;24&quot;
		&quot;autoResize&quot;		&quot;0&quot;
		&quot;pinCorner&quot;		&quot;0&quot;
		&quot;visible&quot;		&quot;0&quot;
		&quot;enabled&quot;		&quot;1&quot;
		&quot;labelText&quot;		&quot;&quot;
		&quot;textAlignment&quot;		&quot;west&quot;
		&quot;dulltext&quot;		&quot;0&quot;
		&quot;brighttext&quot;	&quot;1&quot;
	}
	&quot;jointeam2&quot;
	{
		&quot;ControlName&quot;		&quot;Button&quot;
		&quot;fieldName&quot;		&quot;jointeam2&quot;
		&quot;xpos&quot;			&quot;76&quot;
		&quot;ypos&quot;			&quot;116&quot;
		&quot;wide&quot;			&quot;148&quot;
		&quot;tall&quot;			&quot;20&quot;
		&quot;autoResize&quot;		&quot;0&quot;
		&quot;pinCorner&quot;		&quot;2&quot;
		&quot;visible&quot;		&quot;1&quot;
		&quot;enabled&quot;		&quot;1&quot;
		&quot;tabPosition&quot;		&quot;3&quot;
		&quot;labelText&quot;		&quot;#TM_Join_Team_2&quot;
		&quot;textAlignment&quot;		&quot;west&quot;
		&quot;dulltext&quot;		&quot;0&quot;
		&quot;brighttext&quot;		&quot;0&quot;
		&quot;command&quot;		&quot;jointeam 2&quot;
	}
	&quot;jointeam3&quot;
	{
		&quot;ControlName&quot;		&quot;Button&quot;
		&quot;fieldName&quot;		&quot;jointeam3&quot;
		&quot;xpos&quot;			&quot;76&quot;
		&quot;ypos&quot;			&quot;148&quot;
		&quot;wide&quot;			&quot;148&quot;
		&quot;tall&quot;			&quot;20&quot;
		&quot;autoResize&quot;		&quot;0&quot;
		&quot;pinCorner&quot;		&quot;2&quot;
		&quot;visible&quot;		&quot;1&quot;
		&quot;enabled&quot;		&quot;1&quot;
		&quot;tabPosition&quot;		&quot;4&quot;
		&quot;labelText&quot;		&quot;#TM_Join_Team_3&quot;
		&quot;textAlignment&quot;		&quot;west&quot;
		&quot;dulltext&quot;		&quot;0&quot;
		&quot;brighttext&quot;		&quot;0&quot;
		&quot;command&quot;		&quot;jointeam 3&quot;
	}	
	&quot;autojoin&quot;
	{
		&quot;ControlName&quot;		&quot;Button&quot;
		&quot;fieldName&quot;		&quot;autojoin&quot;
		&quot;xpos&quot;			&quot;76&quot;
		&quot;ypos&quot;			&quot;212&quot;
		&quot;wide&quot;			&quot;148&quot;
		&quot;tall&quot;			&quot;20&quot;
		&quot;autoResize&quot;		&quot;0&quot;
		&quot;pinCorner&quot;		&quot;2&quot;
		&quot;visible&quot;		&quot;1&quot;
		&quot;enabled&quot;		&quot;1&quot;
		&quot;tabPosition&quot;		&quot;1&quot;
		&quot;labelText&quot;		&quot;#TM_Auto_Join&quot;
		&quot;textAlignment&quot;		&quot;west&quot;
		&quot;dulltext&quot;		&quot;0&quot;
		&quot;brighttext&quot;		&quot;0&quot;
		&quot;command&quot;		&quot;jointeam 0&quot;
		&quot;Default&quot;		&quot;1&quot;
	}
	&quot;jointeam1&quot;
	{
		&quot;ControlName&quot;		&quot;Button&quot;
		&quot;fieldName&quot;		&quot;jointeam1&quot;
		&quot;xpos&quot;			&quot;76&quot;
		&quot;ypos&quot;			&quot;244&quot;
		&quot;wide&quot;			&quot;148&quot;
		&quot;tall&quot;			&quot;20&quot;
		&quot;autoResize&quot;		&quot;0&quot;
		&quot;pinCorner&quot;		&quot;2&quot;
		&quot;visible&quot;		&quot;1&quot;
		&quot;enabled&quot;		&quot;1&quot;
		&quot;tabPosition&quot;		&quot;2&quot;
		&quot;labelText&quot;		&quot;#TM_Join_Team_1&quot;
		&quot;textAlignment&quot;		&quot;west&quot;
		&quot;dulltext&quot;		&quot;0&quot;
		&quot;brighttext&quot;		&quot;0&quot;
		&quot;command&quot;		&quot;jointeam 1&quot;
	}
	&quot;CancelButton&quot;
	{
		&quot;ControlName&quot;		&quot;Button&quot;
		&quot;fieldName&quot;		&quot;CancelButton&quot;
		&quot;xpos&quot;			&quot;76&quot;
		&quot;ypos&quot;			&quot;276&quot;
		&quot;wide&quot;			&quot;148&quot;
		&quot;tall&quot;			&quot;20&quot;
		&quot;autoResize&quot;		&quot;0&quot;
		&quot;pinCorner&quot;		&quot;2&quot;
		&quot;visible&quot;		&quot;1&quot;
		&quot;enabled&quot;		&quot;1&quot;
		&quot;tabPosition&quot;		&quot;0&quot;
		&quot;labelText&quot;		&quot;#TM_Cancel&quot;
		&quot;textAlignment&quot;		&quot;west&quot;
		&quot;dulltext&quot;		&quot;0&quot;
		&quot;brighttext&quot;		&quot;0&quot;
		&quot;Command&quot;		&quot;vguicancel&quot;
	}
}</pre>
<a name="Menu_Command"></a><h2><span class="editsection">[<a href="/wiki/index.php?title=HL2:_Creating_Teams&amp;action=edit&amp;section=4" title="Edit section: Menu Command">edit</a>]</span> <span class="mw-headline">Menu Command</span></h2>
<p>The only thing missing to show the menu is a command to bring it up on screen. <b>cl_dll/baseviewport.cpp</b> already implements a command that you can enter from the console to show any panel:
</p>
<pre>CON_COMMAND( showpanel, "Shows a viewport panel &lt;name&gt;" )
</pre>
<p>but making a team menu command is no big deal: 
</p>
<pre>CON_COMMAND( chooseteam, &quot;Opens a menu for teamchoose&quot; )
{
 if (&nbsp;!gViewPortInterface )
  return;
 gViewPortInterface-&gt;ShowPanel( &quot;team&quot;, true );
}</pre>
<p>With this code, if you enter the command "chooseteam" in the console it will show the menu. 
</p>
<a name="Localization"></a><h2><span class="editsection">[<a href="/wiki/index.php?title=HL2:_Creating_Teams&amp;action=edit&amp;section=5" title="Edit section: Localization">edit</a>]</span> <span class="mw-headline">Localization</span></h2>
<p>If you do not already have a &lt;modname&gt;_&lt;language&gt;.txt in your mod's resource folder, you will need to create one.
</p><p>The example below has been extracted from the HL2MP cache and modified to include team names from the team menu. Save it as &lt;modname&gt;_english.txt into your mod's resource folder.
</p><p>If you already have a &lt;modname&gt;_english.txt file, you can copy just the team parts from the example below and paste them into your existing file.
</p>
<pre>&quot;lang&quot; 
{ 
&quot;Language&quot; &quot;English&quot; 
&quot;Tokens&quot; 
{ 

&quot;TM_Join_Team&quot;     &quot;Join a Team&quot;
&quot;TM_Join_Team_1&quot;   &quot;Spectate&quot;
&quot;TM_Join_Team_2&quot;   &quot;Team Combine&quot;
&quot;TM_Join_Team_3&quot;   &quot;Team Rebels&quot;
&quot;TM_Auto_Join&quot;     &quot;Auto-Select&quot;
&quot;TM_Cancel&quot;        &quot;Cancel&quot;

&quot;hl2_AmmoFull&quot;			&quot;FULL&quot;

&quot;HL2_357Handgun&quot;	&quot;.357 MAGNUM&quot;
&quot;HL2_Pulse_Rifle&quot;	&quot;OVERWATCH STANDARD ISSUE\n(PULSE-RIFLE)&quot;
&quot;HL2_Bugbait&quot;		&quot;PHEROPOD\n(BUGBAIT)&quot;
&quot;HL2_Crossbow&quot;		&quot;CROSSBOW&quot;
&quot;HL2_Crowbar&quot;		&quot;CROWBAR&quot;
&quot;HL2_Grenade&quot;		&quot;GRENADE&quot;
&quot;HL2_GravityGun&quot;	&quot;ZERO-POINT ENERGY GUN\n(GRAVITY GUN)&quot;
&quot;HL2_Pistol&quot;		&quot;9MM PISTOL&quot;
&quot;HL2_RPG&quot;		&quot;RPG\n(ROCKET PROPELLED GRENADE)&quot;
&quot;HL2_Shotgun&quot;		&quot;SHOTGUN&quot;
&quot;HL2_SMG1&quot;		&quot;SMG\n(SUBMACHINE GUN)&quot;
&quot;HL2_SLAM&quot;		&quot;S.L.A.M\n(Selectable Lightweight Attack Munition)&quot;
&quot;HL2_StunBaton&quot;		&quot;STUNSTICK&quot;

&quot;HL2_357Handgun_Menu&quot;	&quot;.357 MAGNUM&quot;
&quot;HL2_Pulse_Rifle_Menu&quot;	&quot;PULSE RIFLE&quot;
&quot;HL2_Crossbow_Menu&quot;	&quot;CROSSBOW&quot;
&quot;HL2_Crowbar_Menu&quot;	&quot;CROWBAR&quot;
&quot;HL2_Grenade_Menu&quot;	&quot;GRENADE&quot;
&quot;HL2_GravityGun_Menu&quot;	&quot;GRAVITY GUN&quot;
&quot;HL2_Pistol_Menu&quot;	&quot;9MM PISTOL&quot;
&quot;HL2_RPG_Menu&quot;		&quot;RPG&quot;
&quot;HL2_Shotgun_Menu&quot;	&quot;SHOTGUN&quot;
&quot;HL2_SMG1_Menu&quot;		&quot;SMG&quot;
&quot;HL2_SLAM_Menu&quot;		&quot;S.L.A.M&quot;
&quot;HL2_StunBaton_Menu&quot;	&quot;STUNSTICK&quot;

&quot;ScoreBoard_Player&quot;		&quot;%s1    -   %s2 player&quot;
&quot;ScoreBoard_Players&quot;		&quot;%s1    -   %s2 players&quot;
&quot;ScoreBoard_Deathmatch&quot;		&quot;Deathmatch&quot;
&quot;ScoreBoard_TeamDeathmatch&quot;	&quot;Team Deathmatch&quot;
&quot;Playerid_sameteam&quot;		&quot;Friend: %s1 Health: %s2&quot;
&quot;Playerid_diffteam&quot;		&quot;Enemy: %s1&quot;
&quot;Playerid_noteam&quot;		&quot;%s1 Health:%s2&quot;
&quot;Team&quot;				&quot;Team %s1&quot;

&quot;Game_connected&quot;			&quot;%s1 connected&quot;
&quot;Game_disconnected&quot;			&quot;%s1 has left the game&quot;
&quot;Cannot_Be_Spectator&quot;			&quot;This server does not allow spectating&quot;

} 
}</pre>
<p>If you take a look back at <b>TeamMenu.res</b>, you'll find labeltexts beginning with a '#'. These labels are replaced by their counterparts in the translation file, only without the '#'. For example <b>#TM_Join_Team</b> will be replaced with "Join a Team" if your Steam language is set to English. For other languages you need to create additional files, like <b>&lt;modname&gt;_german</b>, <b>&lt;modname&gt;_french.txt</b>, etc.
</p><p>Using the example TeamMenu.res provided above, you can also display an HTML mapinfo file next to the team menu. Just create a simple HTML file and fill it with map information. It should be named &lt;mapname&gt;_&lt;language&gt;.html and be located in &lt;modname&gt;/resource/maphtml/
</p>
<a name="Forcing_Teamplay"></a><h2><span class="editsection">[<a href="/wiki/index.php?title=HL2:_Creating_Teams&amp;action=edit&amp;section=6" title="Edit section: Forcing Teamplay">edit</a>]</span> <span class="mw-headline">Forcing Teamplay</span></h2>
<p>We will now force HL2MP to be teamplay only. It will use the existing teams (Combine and Rebels) but you will learn how to change the team names if you wish.
</p><p>First ensure that you have 3 teams defined in <b>shareddefs.h</b>:
</p>
<pre>#define TEAM_INVALID			-1
#define TEAM_UNASSIGNED			0
#define TEAM_SPECTATOR			1</pre>
<p><code>TEAM_COMBINE</code> and <code>TEAM_REBELS</code> should <b>NOT</b> be defined here unless you are modding a from-scratch Source SDK. Here we are modding a deathmatch SDK, so the two teams have already been defined in an enum in hl2mpgamerules.h
</p><p><br />
Now open <b>teamplay_gamerules.cpp</b>, and in the function <b>bool CTeamplayRules::ClientCommand( const char *pcmd, CBaseEntity *pEdict )</b> <i>below</i> the lines
</p>
<pre>	if( BaseClass::ClientCommand(pcmd, pEdict) )
		return true;</pre>
<p>add these lines:
</p>
<pre>	if (pEdict-&gt;IsPlayer() &amp;&amp; static_cast&lt;CBasePlayer *&gt;(pEdict)-&gt;ClientCommand(pcmd))
	{
		return true;
	}</pre>
<p>to make the link between the call of CTeamMenu::OnCommand and CBasePlayer::ClientCommand 
</p><p><br />
In player.cpp, in the function <b>bool CBasePlayer::ClientCommand(const char *cmd)</b> we will add 
</p>
<pre>else if ( stricmp( cmd, &quot;jointeam&quot; ) == 0 ) //start jointeam
{
	if ( engine-&gt;Cmd_Argc() &lt; 2 )
		return true;

	int team = atoi( engine-&gt;Cmd_Argv(1) );

	//dont do anything if you join your own team
	if ( team == GetTeamNumber() )
		return true;

	//auto assign if you join team 0
	if ( team == 0 )
	{
		if ( g_Teams[TEAM_COMBINE]-&gt;GetNumPlayers() &gt; g_Teams[TEAM_REBELS]-&gt;GetNumPlayers() )
			team = TEAM_REBELS;
		else
			team = TEAM_COMBINE;
	}

	if (&nbsp;!IsDead() )
	{
		if ( GetTeamNumber()&nbsp;!= TEAM_UNASSIGNED )
		{
			CommitSuicide();
			IncrementFragCount(1); //adds 1 frag to balance out the 1 subtracted for killing yourself
		}
	}

	ChangeTeam( team );

	return true;
} //end jointeam</pre>
<p>Notice the test to check if the player belongs to TEAM_UNASSIGNED, this removes the dead body falling on the floor when we connect to a team.
</p><p>Also to make it compile correctly add this include in <b>player.cpp</b> to the top of the file
</p>
<pre>
#include &quot;hl2mp_gamerules.h&quot;
</pre>
<p><br />
And finally, to force teamplay to be on all the time (even if mp_teamplay is set to 0), go into <b>hl2mp_gamerules.cpp</b> and search for the line
</p>
<pre>m_bTeamPlayEnabled = teamplay.GetBool();
</pre>
<p>and replace it with
</p>
<pre>m_bTeamPlayEnabled = true;
</pre>
<p><br />
</p>
<a name="Final_Touches"></a><h2><span class="editsection">[<a href="/wiki/index.php?title=HL2:_Creating_Teams&amp;action=edit&amp;section=7" title="Edit section: Final Touches">edit</a>]</span> <span class="mw-headline">Final Touches</span></h2>
<p>We're almost done, but there are first a few more things we need to do. First, we need to force players to join Spectator as soon as they connect to the server.
</p><p><br />
In <b>hl2mp_player.cpp</b>, find function <b>void CHL2MP_Player::PickDefaultSpawnTeam( void )</b> and comment the entire function.
Add this in its place:
</p>
<pre>void CHL2MP_Player::PickDefaultSpawnTeam( void )
{
    if ( GetTeamNumber() == 0 )
    {
        if ( HL2MPRules()-&gt;IsTeamplay() == false )
        {
            if ( GetModelPtr() == NULL )
            {
                ChangeTeam( TEAM_UNASSIGNED );
            }
        }
        else
        {
            ChangeTeam( TEAM_SPECTATOR );
        }
    }
}</pre>
<p>Now find function <b>void CHL2MP_Player::Spawn(void)</b> and add this to the end of that function:
</p>
<pre>if ( GetTeamNumber()&nbsp;!= TEAM_SPECTATOR )
{
	StopObserverMode();
}
else
{
	//if we are a spectator then go into roaming mode
	StartObserverMode( OBS_MODE_ROAMING );
}</pre>
<p><br />
And lastly we will make the team menu pop up after the MOTD is closed, so the player knows to join a team.
</p><p>In <b>hl2mp_client.cpp</b> find the line 
</p>
<pre>pPlayer-&gt;ShowViewPortPanel( PANEL_INFO, true, data );
</pre>
<p>and add this ABOVE it:
</p>
<pre>pPlayer-&gt;ShowViewPortPanel( PANEL_TEAM, true, data );
</pre>
<p>(This is really just a temporary solution; what it does is bring up the team menu, then brings up the motd over it so when you close the motd the team menu appears to pop up)
</p><p><br />
One final thing: If you want to change the names of your teams (Combine and Rebels), you do not need to change the predefined names. If you're modding the Deathmatch SDK and decided to change TEAM_COMBINE and TEAM_REBELS in hl2mp_gamerules.h to something else, you'd have to find all instances of those everywhere in the SDK and change them to match, which is a big hassle and likely to cause problems.
</p><p>You can change the visual name appearance of your teams very easily in the file <b>hl2mp_gamerules.cpp</b> by searching for the line 
</p>
<pre>char *sTeamNames[] =
</pre>
<p>Below it you will notice the names for all the defined teams, including Combine and Rebels. Just change those names and your teams will appear with the names on the scoreboard and HUD. To change their names in the Team Menu that we created earlier, you can edit &lt;modname&gt;_english.txt.
</p>
<hr />
<p>That should be everything you need to do to turn your Deathmatch mod into Teamplay Only. I may have missed something, so feel free to edit it in or discuss it in the talk page. --<a href="/wiki/index.php?title=User:Wildfire" title="User:Wildfire">Wildfire</a> 23:19, 10 December 2006 (EST)
</p>
<!-- Saved in parser cache with key gneu922_wiki:pcache:idhash:1502-0!1!0!!en!2 and timestamp 20070416215121 -->
<div class="printfooter">
Retrieved from "<a href="http://www.gneu.org/wiki/index.php?title=HL2:_Creating_Teams">http://www.gneu.org/wiki/index.php?title=HL2:_Creating_Teams</a>"</div>
			<div id="catlinks"><p class='catlinks'><a href="/wiki/index.php?title=Special:Categories" title="Special:Categories">Category</a>: <span dir='ltr'><a href="/wiki/index.php?title=Category:HL2_Tutorials" title="Category:HL2 Tutorials">HL2 Tutorials</a></span></p></div>			<!-- end content -->
			<div class="visualClear"></div>
		</div>
	</div>
		</div>
		<div id="column-one">
	<div id="p-cactions" class="portlet">
		<h5>Views</h5>
		<div class="pBody">
			<ul>
						 <li id="ca-nstab-main" class="selected"><a href="/wiki/index.php?title=HL2:_Creating_Teams">Article</a></li>
						 <li id="ca-talk"><a href="/wiki/index.php?title=Talk:HL2:_Creating_Teams">Discussion</a></li>
						 <li id="ca-edit"><a href="/wiki/index.php?title=HL2:_Creating_Teams&amp;action=edit">Edit</a></li>
						 <li id="ca-history"><a href="/wiki/index.php?title=HL2:_Creating_Teams&amp;action=history">History</a></li>
				</ul>
		</div>
	</div>
	<div class="portlet" id="p-personal">
		<h5>Personal tools</h5>
		<div class="pBody">
			<ul>
				<li id="pt-login"><a href="/wiki/index.php?title=Special:Userlogin&amp;returnto=HL2:_Creating_Teams">Log in / create account</a></li>
			</ul>
		</div>
	</div>
	<div class="portlet" id="p-logo">
		<a style="background-image: url(/wiki/skins/common/images/wiki.png);" href="/wiki/index.php?title=Main_Page" title="Main Page"></a>
	</div>
	<script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script>
		<div class='portlet' id='p-navigation'>
		<h5>Navigation</h5>
		<div class='pBody'>
			<ul>
				<li id="n-mainpage"><a href="/wiki/index.php?title=Main_Page">Main Page</a></li>
				<li id="n-portal"><a href="/wiki/index.php?title=Gneu.org:Community_Portal">Community portal</a></li>
				<li id="n-tutorial"><a href="/wiki/index.php?title=Category:Tutorial">Tutorials</a></li>
				<li id="n-links"><a href="http://www.gneu.org/wiki/index.php?title=Links">Links</a></li>
				<li id="n-currentevents"><a href="/wiki/index.php?title=Current_events">Current events</a></li>
				<li id="n-recentchanges"><a href="/wiki/index.php?title=Special:Recentchanges">Recent changes</a></li>
				<li id="n-randompage"><a href="/wiki/index.php?title=Special:Random">Random page</a></li>
				<li id="n-help"><a href="/wiki/index.php?title=Help:Contents">Help</a></li>
				<li id="n-sitesupport"><a href="/wiki/index.php?title=Gneu.org:Site_support">Donations</a></li>
			</ul>
		</div>
	</div>
		<div id="p-search" class="portlet">
		<h5><label for="searchInput">Search</label></h5>
		<div id="searchBody" class="pBody">
			<form action="/wiki/index.php?title=Special:Search" id="searchform"><div>
				<input id="searchInput" name="search" type="text" accesskey="f" value="" />
				<input type='submit' name="go" class="searchButton" id="searchGoButton"	value="Go" />&nbsp;
				<input type='submit' name="fulltext" class="searchButton" id="mw-searchButton" value="Search" />
			</div></form>
		</div>
	</div>
	<div class="portlet" id="p-tb">
		<h5>Toolbox</h5>
		<div class="pBody">
			<ul>
				<li id="t-whatlinkshere"><a href="/wiki/index.php?title=Special:Whatlinkshere/HL2:_Creating_Teams">What links here</a></li>
				<li id="t-recentchangeslinked"><a href="/wiki/index.php?title=Special:Recentchangeslinked/HL2:_Creating_Teams">Related changes</a></li>
<li id="t-upload"><a href="/wiki/index.php?title=Special:Upload">Upload file</a></li>
<li id="t-specialpages"><a href="/wiki/index.php?title=Special:Specialpages">Special pages</a></li>
				<li id="t-print"><a href="/wiki/index.php?title=HL2:_Creating_Teams&amp;printable=yes">Printable version</a></li>				<li id="t-permalink"><a href="/wiki/index.php?title=HL2:_Creating_Teams&amp;oldid=1940">Permanent link</a></li>			</ul>
		</div>
	</div>
		</div><!-- end of the left (by default at least) column -->
			<div class="visualClear"></div>
			<div id="footer">
				<div id="f-poweredbyico"><a href="http://www.mediawiki.org/"><img src="/wiki/skins/common/images/poweredby_mediawiki_88x31.png" alt="Powered by MediaWiki" /></a></div>
				<div id="f-copyrightico"><a href="http://www.gnu.org/copyleft/fdl.html"><img src="/wiki/skins/common/images/gnu-fdl.png" alt='GNU Free Documentation License 1.2' /></a></div>
			<ul id="f-list">
				<li id="lastmod"> This page was last modified 14:09, 14 December 2006.</li>
				<li id="viewcount">This page has been accessed 509 times.</li>
				<li id="copyright">Content is available under <a href="http://www.gnu.org/copyleft/fdl.html" class="external " title="http://www.gnu.org/copyleft/fdl.html" rel="nofollow">GNU Free Documentation License 1.2</a>.</li>
				<li id="privacy"><a href="/wiki/index.php?title=Gneu.org:Privacy_policy" title="Gneu.org:Privacy policy">Privacy policy</a></li>
				<li id="about"><a href="/wiki/index.php?title=Gneu.org:About" title="Gneu.org:About">About Gneu.org</a></li>
				<li id="disclaimer"><a href="/wiki/index.php?title=Gneu.org:General_disclaimer" title="Gneu.org:General disclaimer">Disclaimers</a></li>
			</ul>
		</div>
		
	
		<script type="text/javascript">if (window.runOnloadHook) runOnloadHook();</script>
</div>
<!-- Served by sh95.surpasshosting.com in 1.021 secs. --></body></html>
