<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jailbreak: Source &#187; Programming</title>
	<atom:link href="http://blog.jailbreaksource.com/?feed=rss2&#038;cat=4" rel="self" type="application/rss+xml" />
	<link>http://blog.jailbreaksource.com</link>
	<description>Source SDK Development Blog</description>
	<lastBuildDate>Thu, 08 Apr 2010 11:54:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Steam.inf &#8211; Playing SourceSDK Base</title>
		<link>http://blog.jailbreaksource.com/?p=1211</link>
		<comments>http://blog.jailbreaksource.com/?p=1211#comments</comments>
		<pubDate>Sun, 10 Jan 2010 16:03:46 +0000</pubDate>
		<dc:creator>Wills</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://blog.jailbreaksource.com/?p=1211</guid>
		<description><![CDATA[Just a quick one today, first blog post in almost six months! We&#8217;ve been a little busy finishing Jailbreak: Source 0.6! One of bugs we had for absolutely ages was finally fixed last week after Lodle from Golden Eye: Source helped us out. So I thought I&#8217;d repost this here in case anyone else developing [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick one today, first blog post in almost six months! We&#8217;ve been a little busy finishing Jailbreak: Source 0.6! One of bugs we had for absolutely ages was finally fixed last week after Lodle from Golden Eye: Source helped us out. So I thought I&#8217;d repost this here in case anyone else developing an Orange Box mod has the same issue.</p>
<p>Basically, what was happening was that instead of Steam Friends saying we were playing Jailbreak: Source 0.6, it would say we were all playing Source SDK Base. This meant that people weren&#8217;t able to join on other players, they would have to load up the game and find the server their friends were playing on. Not an ideal situation!</p>
<p>The fix was creating a file called Steam.inf, which you place inside the base directory of your mod. Inside this file simply put the following line.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">appID=218</div></td></tr></tbody></table></div>
<p>That&#8217;s it! Now when you start up your mod, and join a server, you&#8217;ll be playing&#8230; your mod!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jailbreaksource.com/?feed=rss2&amp;p=1211</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Snippet: Fixing Weapon View Bob</title>
		<link>http://blog.jailbreaksource.com/?p=1057</link>
		<comments>http://blog.jailbreaksource.com/?p=1057#comments</comments>
		<pubDate>Fri, 19 Jun 2009 12:00:59 +0000</pubDate>
		<dc:creator>Dogmeat</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[weapons]]></category>

		<guid isPermaLink="false">http://blog.jailbreaksource.com/?p=1057</guid>
		<description><![CDATA[Quick one: ever notice that weapon view bob, that is the weapon moving in time with the player as they walk, doesn&#8217;t work on certain weapons?
Me either, but weapons that derive from CHL2MPMachineGun don&#8217;t exhibit this behaviour.
It turns out that this is because CHL2MPMachineGun inherits directly from CWeaponHL2MPBase, instead of CBaseHL2MPCombatWeapon like all the other [...]]]></description>
			<content:encoded><![CDATA[<p>Quick one: ever notice that weapon view bob, that is the weapon moving in time with the player as they walk, doesn&#8217;t work on certain weapons?</p>
<p>Me either, but weapons that derive from CHL2MPMachineGun don&#8217;t exhibit this behaviour.</p>
<p>It turns out that this is because CHL2MPMachineGun inherits directly from CWeaponHL2MPBase, instead of CBaseHL2MPCombatWeapon like all the other weapons.</p>
<p>The fix is simple, in weapon_hlwmpbase_machinegun.h just replace</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339900;">#include &quot;weapon_hl2mpbase.h&quot;</span></div></td></tr></tbody></table></div>
<p>with</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339900;">#include &quot;weapon_hl2mpbasehlmpcombatweapon.h&quot;</span></div></td></tr></tbody></table></div>
<p>and then replace</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000ff;">class</span> CHL2MPMachineGun <span style="color: #008080;">:</span> <span style="color: #0000ff;">public</span> CWeaponHL2MPBase</div></td></tr></tbody></table></div>
<p>with</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000ff;">class</span> CHL2MPMachineGun <span style="color: #008080;">:</span> <span style="color: #0000ff;">public</span> CBaseHL2MPCombatWeapon</div></td></tr></tbody></table></div>
<p>And that will give you your view bob back.CBaseHL2MPCombatWeapon also inherits CWeaponHL2MPBase so adding CBahseHL2MPCombatWeapon into the inheritance hierarchy gives you back the functionality that deals with setting up the view bob.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jailbreaksource.com/?feed=rss2&amp;p=1057</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Snippet: Getting Bound Keys</title>
		<link>http://blog.jailbreaksource.com/?p=1039</link>
		<comments>http://blog.jailbreaksource.com/?p=1039#comments</comments>
		<pubDate>Mon, 15 Jun 2009 12:00:10 +0000</pubDate>
		<dc:creator>Dogmeat</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[hud]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://blog.jailbreaksource.com/?p=1039</guid>
		<description><![CDATA[Just a really quick snippet today.
Jailbreak has reworked the weapon selection HUD, and as part of this there are two special weapons that have special keys; the Grav Gun and the Medi-Gun.
As some of our testers use non-standard key configurations, they&#8217;ve been whinging at me to make sure that the key that&#8217;s overlaid on top [...]]]></description>
			<content:encoded><![CDATA[<p>Just a really quick snippet today.</p>
<p>Jailbreak has reworked the weapon selection HUD, and as part of this there are two special weapons that have special keys; the Grav Gun and the Medi-Gun.</p>
<p>As some of our testers use non-standard key configurations, they&#8217;ve been whinging at me to make sure that the key that&#8217;s overlaid on top of the weapon, to let you know what key to press, should be updated based on the current config.</p>
<p>After a little digging around, I found that you can get a key for a given binding quite easily:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000ff;">const</span> <span style="color: #0000ff;">char</span> <span style="color: #000040;">*</span>key <span style="color: #000080;">=</span> engine<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>Key_LookupBinding<span style="color: #008000;">&#40;</span> <span style="color: #FF0000;">&quot;phys_swap&quot;</span> <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></div></td></tr></tbody></table></div>
<p>Just replace &#8220;phys_swap&#8221; with the command you want to know the key for and you&#8217;re done!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jailbreaksource.com/?feed=rss2&amp;p=1039</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Keeping Players Updated With CPlayerResource</title>
		<link>http://blog.jailbreaksource.com/?p=839</link>
		<comments>http://blog.jailbreaksource.com/?p=839#comments</comments>
		<pubDate>Tue, 02 Jun 2009 12:00:34 +0000</pubDate>
		<dc:creator>Dogmeat</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[sdk]]></category>

		<guid isPermaLink="false">http://blog.jailbreaksource.com/?p=839</guid>
		<description><![CDATA[One of the issues I ran accross when first implementing Jailbreak was finding that even though players had a flag in the CHL2MP_Player class to mark them as in or out of jail and it was setup as a network var, this wasn&#8217;t always being sent down to all clients.
I later discovered this was due [...]]]></description>
			<content:encoded><![CDATA[<p>One of the issues I ran accross when first implementing Jailbreak was finding that even though players had a flag in the CHL2MP_Player class to mark them as in or out of jail and it was setup as a network var, this wasn&#8217;t always being sent down to all clients.</p>
<p>I later discovered this was due to the PVS (<a href="http://developer.valvesoftware.com/wiki/PVS">Potentially Visible Set</a>). The PVS defines what you can currently see, and in order to conserve bandwidth, only data for players within that area is transmitted to you. This means that once another player is outside your current PVS, the bulk of their data is no longer kept up to date, including items such as position, velocity and so on.</p>
<p>If you have some data that should always be updated to all players, such as score, health, or in our case the jailed flag, you can make use of the CPlayerResource class which is designed for this very purpose.</p>
<p>The rest of this post will walk you through adding a new item of data to this class.</p>
<h2>Server</h2>
<p>We&#8217;ll start on the server side in player_resource.h, begin by finding</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">CNetworkArray<span style="color: #008000;">&#40;</span> <span style="color: #0000ff;">int</span>, m_iHealth, MAX_PLAYERS<span style="color: #000040;">+</span>1 <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></div></td></tr></tbody></table></div>
<p>and adding the following below it:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">CNetworkArray<span style="color: #008000;">&#40;</span> <span style="color: #0000ff;">int</span>, m_bInJail, MAX_PLAYERS<span style="color: #000040;">+</span>1 <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></div></td></tr></tbody></table></div>
<p>This defines our new data item. Next we need to add this to the send table so that it gets transmitted to the client, so in player_resource.cpp find:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">SendPropArray3<span style="color: #008000;">&#40;</span> SENDINFO_ARRAY3<span style="color: #008000;">&#40;</span>m_iHealth<span style="color: #008000;">&#41;</span>, SendPropInt<span style="color: #008000;">&#40;</span> SENDINFO_ARRAY<span style="color: #008000;">&#40;</span>m_iHealth<span style="color: #008000;">&#41;</span>, <span style="color: #0000dd;">10</span>, SPROP_UNSIGNED <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span>,</div></td></tr></tbody></table></div>
<p>and add the following below it to make sure it gets transmitted:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">SendPropArray3<span style="color: #008000;">&#40;</span> SENDINFO_ARRAY3<span style="color: #008000;">&#40;</span>m_bInJail<span style="color: #008000;">&#41;</span>, SendPropInt<span style="color: #008000;">&#40;</span> SENDINFO_ARRAY<span style="color: #008000;">&#40;</span>m_bInJail<span style="color: #008000;">&#41;</span>, <span style="color: #0000dd;">1</span>, SPROP_UNSIGNED <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span>,</div></td></tr></tbody></table></div>
<p>Finally for the server side we just need to update the new array so that it gets transmitted, so in the same file find the UpdatePlayerData function, and underneath where m_iHealth is set, add the following:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">//JB: set the jail state &amp; perks</span><br />
CHL2MP_Player<span style="color: #000040;">*</span> hl2Player <span style="color: #000080;">=</span> ToHL2MPPlayer<span style="color: #008000;">&#40;</span>pPlayer<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>hl2Player<span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; m_bInJail.<span style="color: #007788;">Set</span><span style="color: #008000;">&#40;</span>i, hl2Player<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>IsInJail<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
<span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<p>And add an include to the top of the file for hl2mp_player.h. This simply uses a function that I already added to CHL2MP_Player to determine if the player is in jail and sets the value accordingly.</p>
<p>It&#8217;s arguable whether this is the best approach as it could be better to subclass CPlayerResource and add things specific to our mod there, but this will do for now.</p>
<h2>Client</h2>
<p>Moving on to the client, we need to set it up to receive the new data we just added, so in c_playerresource.h find:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000ff;">int</span> m_iHealth<span style="color: #008000;">&#91;</span>MAX_PLAYERS<span style="color: #000040;">+</span>1<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span></div></td></tr></tbody></table></div>
<p>and add below it a variable to hold our new field:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000ff;">bool</span> m_bInJail<span style="color: #008000;">&#91;</span>MAX_PLAYERS<span style="color: #000040;">+</span>1<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span></div></td></tr></tbody></table></div>
<p>Whilst we&#8217;re here, we can also add a declaration for an accessor to get access to the new information, so in the public section of the class add:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000ff;">virtual</span> <span style="color: #0000ff;">bool</span>&nbsp; &nbsp; IsInJail<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> index<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></div></td></tr></tbody></table></div>
<p>Moving on to c_playerresource.cpp, first find:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">RecvPropArray3<span style="color: #008000;">&#40;</span> RECVINFO_ARRAY<span style="color: #008000;">&#40;</span>m_iHealth<span style="color: #008000;">&#41;</span>, RecvPropInt<span style="color: #008000;">&#40;</span> RECVINFO<span style="color: #008000;">&#40;</span>m_iHealth<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>,</div></td></tr></tbody></table></div>
<p>and add:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">RecvPropArray3<span style="color: #008000;">&#40;</span> RECVINFO_ARRAY<span style="color: #008000;">&#40;</span>m_bInJail<span style="color: #008000;">&#41;</span>, RecvPropInt<span style="color: #008000;">&#40;</span> RECVINFO<span style="color: #008000;">&#40;</span>m_bInJail<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>,</div></td></tr></tbody></table></div>
<p>and after:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">DEFINE_PRED_ARRAY<span style="color: #008000;">&#40;</span> m_iHealth, FIELD_INTEGER, MAX_PLAYERS<span style="color: #000040;">+</span><span style="color: #0000dd;">1</span>, FTYPEDESC_PRIVATE <span style="color: #008000;">&#41;</span>,</div></td></tr></tbody></table></div>
<p>add:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">DEFINE_PRED_ARRAY<span style="color: #008000;">&#40;</span> m_bInJail, FIELD_BOOLEAN, MAX_PLAYERS<span style="color: #000040;">+</span><span style="color: #0000dd;">1</span>, FTYPEDESC_PRIVATE <span style="color: #008000;">&#41;</span>,</div></td></tr></tbody></table></div>
<p>This sets up the receive table and prediction data to make sure the new field is kept up to date.</p>
<p>Now, in the constructor add the following to initialise the new field:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000dd;">memset</span><span style="color: #008000;">&#40;</span> m_bInJail, 0, <span style="color: #0000dd;">sizeof</span><span style="color: #008000;">&#40;</span> m_bInJail <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></div></td></tr></tbody></table></div>
<p>And finally add a definition for our accessor that we defined earlier to the end of the file:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000ff;">bool</span> C_PlayerResource<span style="color: #008080;">::</span><span style="color: #007788;">IsInJail</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> index<span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">return</span> m_bInJail<span style="color: #008000;">&#91;</span>index<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span><br />
<span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<h2>Summary</h2>
<p>There you have it, the new field will now be kept up to date on all clients and is accesible through the player resource class:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">g_PR<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>IsInJail<span style="color: #008000;">&#40;</span> playerIndex <span style="color: #008000;">&#41;</span></div></td></tr></tbody></table></div>
<p>One word of warning, as this structure is kept up to date to all clients, be sure not to add too much information to it as it could badly affect network performance.</p>
<p>You should carefully consider whether the data really needs to be kept up to date on every client, and if not, make use of one of the other methods of transferring data to the client.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jailbreaksource.com/?feed=rss2&amp;p=839</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Snippet: Stopping Sounds</title>
		<link>http://blog.jailbreaksource.com/?p=999</link>
		<comments>http://blog.jailbreaksource.com/?p=999#comments</comments>
		<pubDate>Sun, 31 May 2009 12:00:28 +0000</pubDate>
		<dc:creator>Dogmeat</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[sound]]></category>

		<guid isPermaLink="false">http://blog.jailbreaksource.com/?p=999</guid>
		<description><![CDATA[Playing sounds is great, but occasionally you may want to stop a sound that is currently being played. For example there is an execution countdown in Jailbreak that can be averted mid way through, and it was easiest to have this as a single sound that can be stopped as needed.
To do that we can [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.jailbreaksource.com/?p=852">Playing sounds</a> is great, but occasionally you may want to stop a sound that is currently being played. For example there is an execution countdown in Jailbreak that can be averted mid way through, and it was easiest to have this as a single sound that can be stopped as needed.</p>
<p>To do that we can add a new game event which will specify the name of a sound to stop.</p>
<h2>The New Game Event</h2>
<p>Firstly, in resource/modevents.res add the following new event:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&quot;stop_audio&quot;<br />
{<br />
&nbsp; &nbsp; &quot;sound&quot; &nbsp; &nbsp; &quot;string&quot;<br />
}</div></td></tr></tbody></table></div>
<h2>Listening for the Event</h2>
<p>Now we just need to listen for the game event and act on it, so in clientmodeshared.cpp find:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span> Q_strcmp<span style="color: #008000;">&#40;</span> <span style="color: #FF0000;">&quot;teamplay_broadcast_audio&quot;</span>, eventname <span style="color: #008000;">&#41;</span> <span style="color: #000080;">==</span> <span style="color: #0000dd;">0</span> <span style="color: #008000;">&#41;</span></div></td></tr></tbody></table></div>
<p>and add a new else if clause after the closing brace for that one:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span> Q_strcmp<span style="color: #008000;">&#40;</span> <span style="color: #FF0000;">&quot;stop_audio&quot;</span>, eventname <span style="color: #008000;">&#41;</span> <span style="color: #000080;">==</span> 0 <span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">const</span> <span style="color: #0000ff;">char</span> <span style="color: #000040;">*</span>pszSoundName <span style="color: #000080;">=</span> event<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetString<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;sound&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; C_BasePlayer <span style="color: #000040;">*</span>pPlayer <span style="color: #000080;">=</span> C_BasePlayer<span style="color: #008080;">::</span><span style="color: #007788;">GetLocalPlayer</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>pPlayer<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; pPlayer<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>StopSound<span style="color: #008000;">&#40;</span> pszSoundName <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
<span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<p>As you can see, it&#8217;s pretty straight forward. First we get the name of the sound to stop and the local player, then if the player is valid we just call StopSound on them.</p>
<h2>Using It</h2>
<p>That&#8217;s all we need to do to hook up the event; now to actually use it you can simply do the following:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">IGameEvent <span style="color: #000040;">*</span>event <span style="color: #000080;">=</span> gameeventmanager<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>CreateEvent<span style="color: #008000;">&#40;</span> <span style="color: #FF0000;">&quot;stop_audio&quot;</span> <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span> event <span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; event<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>SetString<span style="color: #008000;">&#40;</span> <span style="color: #FF0000;">&quot;sound&quot;</span>, <span style="color: #FF0000;">&quot;Jailbreak.Countdown&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; gameeventmanager<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>FireEvent<span style="color: #008000;">&#40;</span> event <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
<span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<p>Replacing &#8216;Jailbreak.Countdown&#8217; with the name of the sound you wish to stop.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jailbreaksource.com/?feed=rss2&amp;p=999</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Update to Playing Announcement Sounds</title>
		<link>http://blog.jailbreaksource.com/?p=852</link>
		<comments>http://blog.jailbreaksource.com/?p=852#comments</comments>
		<pubDate>Mon, 25 May 2009 12:00:06 +0000</pubDate>
		<dc:creator>Dogmeat</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[sound]]></category>

		<guid isPermaLink="false">http://blog.jailbreaksource.com/?p=852</guid>
		<description><![CDATA[While doing some work on Jailbreak I&#8217;ve just noticed that my post on using SendAudio to send sounds to be played on clients is out of date.
In the orangebox sdk there is a new event named teamplay_broadcast_audio which is already set up to allow you to play announcement like sounds on the client (i.e. sounds [...]]]></description>
			<content:encoded><![CDATA[<p>While doing some work on Jailbreak I&#8217;ve just noticed that my post on using <a href="http://blog.jailbreaksource.com/?p=345">SendAudio</a> to send sounds to be played on clients is out of date.</p>
<p>In the orangebox sdk there is a new event named teamplay_broadcast_audio which is already set up to allow you to play announcement like sounds on the client (i.e. sounds that are heard in the players head, rather than placed in the level somewhere).</p>
<p>You can quite easily rip the function from the roundbased gamerules and place it in your own to make use of it:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000ff;">void</span> CJBGameRules<span style="color: #008080;">::</span><span style="color: #007788;">BroadcastSound</span><span style="color: #008000;">&#40;</span> <span style="color: #0000ff;">int</span> iTeam, <span style="color: #0000ff;">const</span> <span style="color: #0000ff;">char</span> <span style="color: #000040;">*</span>sound <span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666;">//send it to everyone</span><br />
&nbsp; &nbsp; IGameEvent <span style="color: #000040;">*</span>event <span style="color: #000080;">=</span> gameeventmanager<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>CreateEvent<span style="color: #008000;">&#40;</span> <span style="color: #FF0000;">&quot;teamplay_broadcast_audio&quot;</span> <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span> event <span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; event<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>SetInt<span style="color: #008000;">&#40;</span> <span style="color: #FF0000;">&quot;team&quot;</span>, iTeam <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; event<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>SetString<span style="color: #008000;">&#40;</span> <span style="color: #FF0000;">&quot;sound&quot;</span>, sound <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; gameeventmanager<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>FireEvent<span style="color: #008000;">&#40;</span> event <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<p>Then just call it with the team you want and the sound name, like so:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">BroadcastSound<span style="color: #008000;">&#40;</span>TEAM_REBELS, <span style="color: #FF0000;">&quot;Jailbreak.ExecutionAverted&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></div></td></tr></tbody></table></div>
<p>This doesn&#8217;t have much over the previous way of playing sounds as it ultimately works the same way on the client, but it is slightly more concise to call, and of course involves less work to set it up in the first place, which is always a bonus.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jailbreaksource.com/?feed=rss2&amp;p=852</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Snippet: Add Items to Advanced Multiplayer Options</title>
		<link>http://blog.jailbreaksource.com/?p=804</link>
		<comments>http://blog.jailbreaksource.com/?p=804#comments</comments>
		<pubDate>Thu, 21 May 2009 12:00:44 +0000</pubDate>
		<dc:creator>Dogmeat</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://blog.jailbreaksource.com/?p=804</guid>
		<description><![CDATA[Under the multiplayer options tab in your mod you may notice an &#8216;Advanced&#8217; button which by default has nothing in it. This screen allows the user to set client side options through the use of cvars.
To add your own entries all you need to do is create a user_default.scr file in the cfg directory with [...]]]></description>
			<content:encoded><![CDATA[<p>Under the multiplayer options tab in your mod you may notice an &#8216;Advanced&#8217; button which by default has nothing in it. This screen allows the user to set client side options through the use of cvars.</p>
<p>To add your own entries all you need to do is create a user_default.scr file in the cfg directory with the following content:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">// NOTE: &nbsp;THIS FILE IS AUTOMATICALLY REGENERATED, <br />
//DO NOT EDIT THIS HEADER, YOUR COMMENTS WILL BE LOST IF YOU DO<br />
// User options script<br />
//<br />
// Format:<br />
// &nbsp;Version [float]<br />
// &nbsp;Options description followed by <br />
// &nbsp;Options defaults<br />
//<br />
// Option description syntax:<br />
//<br />
// &nbsp;&quot;cvar&quot; { &quot;Prompt&quot; { type [ type info ] } { default } }<br />
//<br />
// &nbsp;type = <br />
// &nbsp; BOOL &nbsp; (a yes/no toggle)<br />
// &nbsp; STRING<br />
// &nbsp; NUMBER<br />
// &nbsp; LIST<br />
//<br />
// type info:<br />
// BOOL &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; no type info<br />
// NUMBER &nbsp; &nbsp; &nbsp; min max range, use -1 -1 for no limits<br />
// STRING &nbsp; &nbsp; &nbsp; no type info<br />
// LIST &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;delimited list of options value pairs<br />
//<br />
//<br />
// default depends on type<br />
// BOOL is &quot;0&quot; or &quot;1&quot;<br />
// NUMBER is &quot;value&quot;<br />
// STRING is &quot;value&quot;<br />
// LIST is &quot;index&quot;, where index &quot;0&quot; is the first element of the list<br />
// Half-Life User Info Configuration Layout Script (stores last settings chosen, too)<br />
// File generated: &nbsp;Fri Jul 15 20:55:55 AM<br />
//<br />
//<br />
// Cvar - &nbsp; Setting<br />
<br />
<br />
VERSION 1.0<br />
<br />
<br />
DESCRIPTION INFO_OPTIONS<br />
{<br />
&nbsp; &nbsp; &quot;cl_showplayernames&quot;<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Show Ally Names&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; { BOOL }<br />
&nbsp; &nbsp; &nbsp; &nbsp; { &quot;1&quot; }<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &quot;cl_autowepswitch&quot;<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Switch Weapon On Pickup&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; { BOOL }<br />
&nbsp; &nbsp; &nbsp; &nbsp; { &quot;0&quot; }<br />
&nbsp; &nbsp; }<br />
}</div></td></tr></tbody></table></div>
<p>Adding new items should be self explanatory.</p>
<p>That&#8217;s all there is to it!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jailbreaksource.com/?feed=rss2&amp;p=804</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Snippets: Find Nearest Ally</title>
		<link>http://blog.jailbreaksource.com/?p=632</link>
		<comments>http://blog.jailbreaksource.com/?p=632#comments</comments>
		<pubDate>Tue, 14 Apr 2009 12:00:48 +0000</pubDate>
		<dc:creator>Dogmeat</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[util]]></category>

		<guid isPermaLink="false">http://blog.jailbreaksource.com/?p=632</guid>
		<description><![CDATA[Just some useful code I came accross; I&#8217;ve no idea if I wrote this or if I found it somewhere, so if it&#8217;s not mine, credit to whoever&#8217;s it is.
If it is mine, credit to Me  
123456789101112131415161718192021222324252627//JB: find the nearest ally
CHL2MP_Player* CHL2MP_Player::FindNearestAlly&#40;&#41;
&#123;
&#160; &#160; const Vector &#38;&#160; vAbsOrigin &#160;&#160; &#160; = GetAbsOrigin&#40;&#41;;
&#160; &#160; float &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>Just some useful code I came accross; I&#8217;ve no idea if I wrote this or if I found it somewhere, so if it&#8217;s not mine, credit to whoever&#8217;s it is.</p>
<p>If it is mine, credit to Me <img src='http://blog.jailbreaksource.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">//JB: find the nearest ally</span><br />
CHL2MP_Player<span style="color: #000040;">*</span> CHL2MP_Player<span style="color: #008080;">::</span><span style="color: #007788;">FindNearestAlly</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">const</span> Vector <span style="color: #000040;">&amp;</span>&nbsp; vAbsOrigin &nbsp;&nbsp; &nbsp; <span style="color: #000080;">=</span> GetAbsOrigin<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">float</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; closestDistSq &nbsp; <span style="color: #000080;">=</span> <span style="color: #0000ff;">FLT_MAX</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; CHL2MP_Player <span style="color: #000040;">*</span> pNearest &nbsp; &nbsp;&nbsp; &nbsp; <span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">float</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; distSq<span style="color: #008080;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> i <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span> i <span style="color: #000080;">&lt;=</span> gpGlobals<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>maxClients<span style="color: #008080;">;</span> i<span style="color: #000040;">++</span> <span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; CHL2MP_Player <span style="color: #000040;">*</span>pPlayer <span style="color: #000080;">=</span> ToHL2MPPlayer<span style="color: #008000;">&#40;</span>UTIL_PlayerByIndex<span style="color: #008000;">&#40;</span> i <span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span> pPlayer <span style="color: #000040;">&amp;&amp;</span> pPlayer <span style="color: #000040;">!</span><span style="color: #000080;">=</span> <span style="color: #0000dd;">this</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>pPlayer<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetTeamNumber<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">!</span><span style="color: #000080;">=</span> this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetTeamNumber<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">continue</span><span style="color: #008080;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; distSq <span style="color: #000080;">=</span> <span style="color: #008000;">&#40;</span> vAbsOrigin <span style="color: #000040;">-</span> pPlayer<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetAbsOrigin<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span>.<span style="color: #007788;">LengthSqr</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>distSq <span style="color: #000080;">&gt;</span> closestDistSq<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">continue</span><span style="color: #008080;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; closestDistSq <span style="color: #000080;">=</span> distSq<span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pNearest <span style="color: #000080;">=</span> pPlayer<span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">return</span> pNearest<span style="color: #008080;">;</span><br />
<span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<p>This lives in CHL2MP_Player and is just a straight forward search going through each player and working out their distance from the local player, storing a pointer to the player if it&#8217;s lower than the current shortest.</p>
<p>It&#8217;s fairly simple to adapt this to search for the nearest player based on a criteria by altering:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>pPlayer<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetTeamNumber<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">!</span><span style="color: #000080;">=</span> this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetTeamNumber<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">continue</span><span style="color: #008080;">;</span></div></td></tr></tbody></table></div>
<p>To continue on players you don&#8217;t care about (or put the rest of the statement in an if statement&#8230;).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jailbreaksource.com/?feed=rss2&amp;p=632</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing HL2MP_Chat_All Chat Issue</title>
		<link>http://blog.jailbreaksource.com/?p=626</link>
		<comments>http://blog.jailbreaksource.com/?p=626#comments</comments>
		<pubDate>Thu, 09 Apr 2009 12:00:27 +0000</pubDate>
		<dc:creator>Dogmeat</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[obsdk]]></category>

		<guid isPermaLink="false">http://blog.jailbreaksource.com/?p=626</guid>
		<description><![CDATA[In our first beta test of the Orange Box version of Jailbreak we had a problem where all chat messages where showing up as &#8220;HL2MP_Chat_All&#8221;, or &#8220;HL2MP_Chat_Team&#8221;.
Turns out this is quite simple to fix; in the resources directory you should have one or more language files named like yourmod_language.txt (e.g. jailbreak_english.txt) which simplifies making your [...]]]></description>
			<content:encoded><![CDATA[<p>In our first beta test of the Orange Box version of Jailbreak we had a problem where all chat messages where showing up as &#8220;HL2MP_Chat_All&#8221;, or &#8220;HL2MP_Chat_Team&#8221;.</p>
<p>Turns out this is quite simple to fix; in the resources directory you should have one or more language files named like yourmod_language.txt (e.g. jailbreak_english.txt) which simplifies making your mod work with multiple languages.</p>
<p>All you need to do is make sure you have the following entries in each language file:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&quot;HL2MP_Chat_Team_Loc&quot; &nbsp; &nbsp; &nbsp; &quot;(TEAM) %s1 @ %s3 : &nbsp;%s2&quot;<br />
&quot;HL2MP_Chat_Team&quot; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;(TEAM) %s1 : &nbsp;%s2&quot;<br />
&quot;HL2MP_Chat_Team_Dead&quot;&nbsp; &nbsp; &nbsp; &quot;*DEAD*(TEAM) %s1 : &nbsp;%s2&quot;<br />
&quot;HL2MP_Chat_Spec&quot; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;(Spectator) %s1 : &nbsp;%s2&quot;<br />
&quot;HL2MP_Chat_All&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;%s1 : &nbsp;%s2&quot;<br />
&quot;HL2MP_Chat_AllDead&quot;&nbsp; &nbsp; &nbsp; &nbsp; &quot;*DEAD* %s1 : &nbsp;%s2&quot;<br />
&quot;HL2MP_Chat_AllSpec&quot;&nbsp; &nbsp; &nbsp; &nbsp; &quot;*SPEC* %s1 : &nbsp;%s2&quot;<br />
&quot;HL2MP_Name_Change&quot; &nbsp; &nbsp; &quot;* %s1 changed name to %s2&quot;</div></td></tr></tbody></table></div>
<p>Note: I&#8217;ve left out some control characters that Firefox / Wordpress editor doesn&#8217;t seem to like, so ideally you should copy these lines from hl2mp_english.txt which can be found in the resources directory in the half-life 2 deathmatch.gcf file.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jailbreaksource.com/?feed=rss2&amp;p=626</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dropping Just the Ammo in the Clip</title>
		<link>http://blog.jailbreaksource.com/?p=634</link>
		<comments>http://blog.jailbreaksource.com/?p=634#comments</comments>
		<pubDate>Tue, 07 Apr 2009 12:00:55 +0000</pubDate>
		<dc:creator>Dogmeat</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[weapons]]></category>

		<guid isPermaLink="false">http://blog.jailbreaksource.com/?p=634</guid>
		<description><![CDATA[If you&#8217;ve followed the weapon dropping post, you may have noticed you can get yourself inifinite ammo by dropping a weapon and picking it up again &#8211; not so good!
In order to fix that we need to make it so that when a weapon is dropped, it records how much ammo it has and only [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve followed the<a href="http://blog.jailbreaksource.com/?p=33"> weapon dropping post</a>, you may have noticed you can get yourself inifinite ammo by dropping a weapon and picking it up again &#8211; not so good!</p>
<p>In order to fix that we need to make it so that when a weapon is dropped, it records how much ammo it has and only gives that to the player when picked up, rather than the default amount.</p>
<p>So, starting in basecombatweapon_shared.h after:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">COutputEvent m_OnCacheInteraction<span style="color: #008080;">;</span></div></td></tr></tbody></table></div>
<p>Add a new variable to track if the weapon was dropped:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000ff;">bool</span> m_bDropped<span style="color: #008080;">;</span></div></td></tr></tbody></table></div>
<p>Then after:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000ff;">void</span> Use<span style="color: #008000;">&#40;</span> CBaseEntity <span style="color: #000040;">*</span>pActivator, CBaseEntity <span style="color: #000040;">*</span>pCaller, USE_TYPE useType, <span style="color: #0000ff;">float</span> value <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></div></td></tr></tbody></table></div>
<p>Add an accessor to that var:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">//JB: dropped accessor</span><br />
<span style="color: #0000ff;">bool</span> WasDropped <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> <span style="color: #0000ff;">return</span> m_bDropped<span style="color: #008080;">;</span> <span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<p>Now in basecombatweapon_shared.cpp in the constructor after:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">OnBaseCombatWeaponCreated<span style="color: #008000;">&#40;</span> <span style="color: #0000dd;">this</span> <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></div></td></tr></tbody></table></div>
<p>Initialise the variable:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">//JB: dropped var</span><br />
m_bDropped <span style="color: #000080;">=</span> <span style="color: #0000ff;">false</span><span style="color: #008080;">;</span></div></td></tr></tbody></table></div>
<p>And in then in CBaseCombatWeapon::Drop right after the first #if !defined( CLIENT_DLL ) set the var to true:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">//JB: set the dropped vars so we dont get given ammo when picked up</span><br />
m_bDropped <span style="color: #000080;">=</span> <span style="color: #0000ff;">true</span><span style="color: #008080;">;</span></div></td></tr></tbody></table></div>
<p>That will just make sure we know when the weapon has been dropped, as opposed to just being spawned.</p>
<p>Now we need to make use of this to prevent additional ammo being given, so in basecombatcharacter.cpp find:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">// If gun doesn't use clips, just give ammo</span><br />
<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetMaxClip1<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #000080;">==</span> <span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
<span style="color: #339900;">#ifdef HL2_DLL</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span> FStrEq<span style="color: #008000;">&#40;</span>STRING<span style="color: #008000;">&#40;</span>gpGlobals<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>mapname<span style="color: #008000;">&#41;</span>, <span style="color: #FF0000;">&quot;d3_c17_09&quot;</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">&amp;&amp;</span> FClassnameIs<span style="color: #008000;">&#40;</span>pWeapon, <span style="color: #FF0000;">&quot;weapon_rpg&quot;</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">&amp;&amp;</span> pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>NameMatches<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;player_spawn_items&quot;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// !!!HACK - Don't give any ammo with the spawn equipment RPG in d3_c17_09. This is a chapter</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// start and the map is way to easy if you start with 3 RPG rounds. It's fine if a player conserves</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// them and uses them here, but it's not OK to start with enough ammo to bypass the snipers completely.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; GiveAmmo<span style="color: #008000;">&#40;</span> 0, pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>m_iPrimaryAmmoType<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">else</span><br />
<span style="color: #339900;">#endif // HL2_DLL</span><br />
&nbsp; &nbsp; GiveAmmo<span style="color: #008000;">&#40;</span>pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetDefaultClip1<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>, pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>m_iPrimaryAmmoType<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <br />
<span style="color: #008000;">&#125;</span><br />
<span style="color: #666666;">// If default ammo given is greater than clip</span><br />
<span style="color: #666666;">// size, fill clips and give extra ammo</span><br />
<span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetDefaultClip1<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #000080;">&gt;</span> &nbsp;pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetMaxClip1<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>m_iClip1 <span style="color: #000080;">=</span> pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetMaxClip1<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; GiveAmmo<span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#40;</span>pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetDefaultClip1<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">-</span> pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetMaxClip1<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>, pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>m_iPrimaryAmmoType<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <br />
<span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<p>And wrap the whole thing in another if statement so it looks like follows:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">//JB: if was dropped, don't give any additional ammo</span><br />
<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span><span style="color: #000040;">!</span>pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>WasDropped<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666;">// If gun doesn't use clips, just give ammo</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetMaxClip1<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #000080;">==</span> <span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
<span style="color: #339900;">#ifdef HL2_DLL</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span> FStrEq<span style="color: #008000;">&#40;</span>STRING<span style="color: #008000;">&#40;</span>gpGlobals<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>mapname<span style="color: #008000;">&#41;</span>, <span style="color: #FF0000;">&quot;d3_c17_09&quot;</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">&amp;&amp;</span> FClassnameIs<span style="color: #008000;">&#40;</span>pWeapon, <span style="color: #FF0000;">&quot;weapon_rpg&quot;</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">&amp;&amp;</span> pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>NameMatches<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;player_spawn_items&quot;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// !!!HACK - Don't give any ammo with the spawn equipment RPG in d3_c17_09. This is a chapter</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// start and the map is way to easy if you start with 3 RPG rounds. It's fine if a player conserves</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// them and uses them here, but it's not OK to start with enough ammo to bypass the snipers completely.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GiveAmmo<span style="color: #008000;">&#40;</span> 0, pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>m_iPrimaryAmmoType<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">else</span><br />
<span style="color: #339900;">#endif // HL2_DLL</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; GiveAmmo<span style="color: #008000;">&#40;</span>pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetDefaultClip1<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>, pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>m_iPrimaryAmmoType<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #666666;">// If default ammo given is greater than clip</span><br />
&nbsp; &nbsp; <span style="color: #666666;">// size, fill clips and give extra ammo</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetDefaultClip1<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #000080;">&gt;</span> &nbsp;pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetMaxClip1<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>m_iClip1 <span style="color: #000080;">=</span> pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetMaxClip1<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; GiveAmmo<span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#40;</span>pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetDefaultClip1<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">-</span> pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetMaxClip1<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>, pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>m_iPrimaryAmmoType<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<p>You may wish to do the same for the secondary ammo below:</p>
<div class="codecolorer-container cpp default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">//JB: if was dropped, don't give any additional ammo</span><br />
<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span><span style="color: #000040;">!</span>pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>WasDropped<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666;">// If gun doesn't use clips, just give ammo</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetMaxClip2<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #000080;">==</span> <span style="color: #000040;">-</span>1<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; GiveAmmo<span style="color: #008000;">&#40;</span>pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetDefaultClip2<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>, pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>m_iSecondaryAmmoType<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #666666;">// If default ammo given is greater than clip</span><br />
&nbsp; &nbsp; <span style="color: #666666;">// size, fill clips and give extra ammo</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span> pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetDefaultClip2<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #000080;">&gt;</span> pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetMaxClip2<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>m_iClip2 <span style="color: #000080;">=</span> pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetMaxClip2<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; GiveAmmo<span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#40;</span>pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetDefaultClip2<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">-</span> pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetMaxClip2<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>, pWeapon<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>m_iSecondaryAmmoType<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<p>Now whenever you drop a weapon, it should just be left with what was in the clip, re-establishing a stable arms market.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jailbreaksource.com/?feed=rss2&amp;p=634</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
