Creating A Multiplayer Weapon

For help, see the VDC Editing Help and Wikipedia cleanup process. Also, remember to check for any notes left by the tagger at this article's talk page.
Creating A HL2 Multiplayer Weapon
Ok so let's get this straight, you're wanting to create a Whole NEW weapon for your new Half Life 2 Multiplayer game right? Now your stuck and need a little tutorial which will tell you what to do right? Well luck is here as i shall teach you how to impliment a new weapon ready to use for your multiplayer game =D
weapon_rifle.cpp
Ok, this is main part so be very careful here.
- Open weapon_357.cpp [server/Source Files/hl2mp/weapons]
- Hit CTRL A + CTRL C
- In your solution just where your 357 is located, right click the Weapons folder then select Add> Add New Item.
- Select CPP in the name part add weapon_rifle.cpp MAKE sure you change the save location down the bottom to [mod dir]\src\game_shared\hl2mp as it is a common file between the server and client.
- In the weapon_rifle.cpp hit CTRL + V hit save (ctrl + s)
- Now for the tricky part. You need to replace every instatnt of CWeapon357 with CWeaponRifle but not the parts which refer to sound files.
All you need to do now is add the same file to the client side, open up the client/Source Files/hl2mp/weapons and right click on the folder and select add existing. Select the same file weapon_rifle.cpp that is in the game_share dir (from before) and click add. Compile and your done.
weapon_rifle.TXT
Ok so now your probabley happy and dandy that theres no errors right? WELL YOU SHOULD BE! that's probabley the hardest part over and done with in my opinion. Right so let's get the weapon in game now shall we? open up weapon_357.txt which is located in MyMod/Scripts/weapon_357.txt. Copy it all, and paste it into a new notepad document edit what you like in here here's mine for this tutorial :)
// Rifle - Wiki tutorial :D WeaponData { // Weapon data is loaded by both the Game and Client DLLs. "printname" "#HL2_Rifle" "viewmodel" "models/weapons/v_shotgun.mdl" "playermodel" "models/weapons/w_annabelle.mdl" "anim_prefix" "shotgun" "bucket" "2" "bucket_position" "1" "clip_size" "2" "primary_ammo" "357" "secondary_ammo" "None" "weight" "2" "item_flags" "0" // Sounds for the weapon. There is a max of 16 sounds per category (i.e. max 16 "single_shot" sounds) SoundData { "empty" "Weapon_Shotgun.Empty" "reload" "Weapon_Shotgun.Reload" "special1" "Weapon_Shotgun.Special1" "single_shot" "Weapon_Shotgun.Single" "double_shot" "Weapon_Shotgun.Double" // NPC WEAPON SOUNDS "reload_npc" "Weapon_Shotgun.NPC_Reload" "single_shot_npc" "Weapon_Shotgun.NPC_Single" } // Weapon Sprite data is loaded by the Client DLL. TextureData { "weapon" { "file" "sprites/w_icons2" "x" "0" "y" "128" "width" "128" "height" "64" } "weapon_s" { "file" "sprites/w_icons2b" "x" "0" "y" "128" "width" "128" "height" "64" } "ammo" { "file" "sprites/a_icons1" "x" "55" "y" "90" "width" "73" "height" "20" } "crosshair" { "file" "sprites/crosshairs" "x" "0" "y" "48" "width" "24" "height" "24" } "autoaim" { "file" "sprites/crosshairs" "x" "0" "y" "48" "width" "24" "height" "24" } } }
Other Usefull Stuff
Want it to be a default weapon? Open up Hl2mp_player.cpp Find this function
void CHL2MP_Player::GiveDefaultItems( void )
If you can not find the above, press ctrl + G and enter the line number 198, this should take you to it.
Add your weapon to the list.
i.e GiveNamedItem( "weapon_rifle" );
Enjoy Your New Weapon
Hey, thanks for viewing my tutorial and i hope it helps and teaches your for the future my
friends =D