Post tutorial Report RSS Adding cl_righthand in Half Life 2

Adding cl_righthand in Half Life 2 for adding CSS models to hl2 so there not on the left hand side of the screen :D

Posted by on - Intermediate Server Side Coding

1. Open up 'c_baseviewmodel.cpp' in your Mods Src folder (C:\MODNAME\src\cl_dll)

2. Scroll down to line 25 and find the line that looks like this:

#ifdef CSTRIKE_DLL 
ConVar cl_righthand( "cl_righthand", "1", FCVAR_ARCHIVE, "Use right-handed view models." ); 
#endif  

Change It To This:

// #ifdef CSTRIKE_DLL 
ConVar cl_righthand( "cl_righthand", "1", FCVAR_ARCHIVE, "Use right-handed view models." ); 
// #endif  

3.Scroll down to line 177 and find the line that looks like this:

//Tony; changed for SDK so that the CSS models can be flipped out of the box.
#if defined( CSTRIKE_DLL ) || defined ( SDK_DLL )
	//Tony; move this up here.
	if (!cl_righthand.GetBool())
		return false;

	// If cl_righthand is set, then we want them all right-handed.
	CBaseCombatWeapon *pWeapon = m_hWeapon.Get();
	if ( pWeapon )
	{
		const FileWeaponInfo_t *pInfo = &pWeapon->GetWpnData();
		//Tony; if they're already built right handed (default) then we can get out.
		if (pInfo->m_bBuiltRightHanded)
			return false;

		return pInfo->m_bAllowFlipping;
	}
#endif

Change It To This:

// #ifdef CSTRIKE_DLL
	// If cl_righthand is set, then we want them all right-handed.
	CBaseCombatWeapon *pWeapon = m_hWeapon.Get();
	if ( pWeapon )
	{
		const FileWeaponInfo_t *pInfo = &pWeapon->GetWpnData();
		return pInfo->m_bAllowFlipping && pInfo->m_bBuiltRightHanded != cl_righthand.GetBool();
	}
// #endif

4. Add a few lines to Your Weapon Script:
Scroll down to where it says "item_flags" "0" and just below it add this:

        "BuiltRightHanded"              "0" 
        "AllowFlipping"                 "1"
	"CSViewModel"			"1"
	"CSWorldModel"			"1"  

e.g. weapon_smg1.txt

// Small Machine Gun 1

WeaponData
{
	// Weapon data is loaded by both the Game and Client DLLs.
	"printname"	"#HL2_SMG1"
	"viewmodel"				"models/weapons/v_smg1.mdl"
	"playermodel"			"models/weapons/w_smg1.mdl"
	"anim_prefix"			"smg2"
	"bucket"				"2"
	"bucket_position"		"0"

	"clip_size"				"45"
	"clip2_size"			"-1"

	"default_clip"			"45"
	"default_clip2"			"-1"

	"primary_ammo"			"SMG1"
	"secondary_ammo"		"SMG1_Grenade"

	"weight"				"3"
	"item_flags"			"0"
	"damage"			"8"


        "BuiltRightHanded"              "0" 
        "AllowFlipping"                 "1"
	"CSViewModel"			"1"
	"CSWorldModel"			"1"  





	// Sounds for the weapon. There is a max of 16 sounds per category (i.e. max 16 "single_shot" sounds)
	SoundData
	{
		"reload"			"Weapon_SMG1.Reload"
		"reload_npc"		"Weapon_SMG1.NPC_Reload"
		"empty"				"Weapon_SMG1.Empty"
		"single_shot"		"Weapon_SMG1.Single"
		"single_shot_npc"	"Weapon_SMG1.NPC_Single"
		"special1"			"Weapon_SMG1.Special1"
		"special2"			"Weapon_SMG1.Special2"
		"double_shot"		"Weapon_SMG1.Double"
		"burst"				"Weapon_SMG1.Burst"
	}

	// Weapon Sprite data is loaded by the Client DLL.
	TextureData
	{
		"weapon"
		{
				"font"		"WeaponIcons"
				"character"	"a"
		}
		"weapon_s"
		{	
				"font"		"WeaponIconsSelected"
				"character"	"a"
		}
		"ammo"
		{
				"font"		"WeaponIcons"
				"character"	"r"
		}
		"ammo2"
		{
				"font"		"WeaponIcons"
				"character"	"t"
		}
		"crosshair"
		{
				"font"		"Crosshairs"
				"character"	"Q"
		}
		"autoaim"
		{
				"file"		"sprites/crosshairs"
				"x"			"0"
				"y"			"48"
				"width"		"24"
				"height"	"24"
		}
	}
}

Hope This Helped You Out :D

Post comment Comments
Shirk
Shirk - - 885 comments

This works great, but there are still many other errors to address, like automatic weapons not using the fire animation correctly, and the FOV is wrong.

Reply Good karma Bad karma+2 votes
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: