Left 4 Dead 2

Left 4 Dead 2

51 ratings
How to Make a Custom Crosshair
By Heb
This guide will show you how to, in a simple and non complicated way, make your own custom crosshair from scratch.
Tranform it into an addon, and use it in-game.
   
Award
Favorite
Favorited
Unfavorite
Introduction
For starters make sure you have these three applications:
  • GCFScape
  • VTFEdit
  • Notepad++

Free photo editing softwares:
  • GIMP
  • Paint NET
Design your crosshair
Use any type of photo editor to make your crosshair. I recommend GIMP or Paint NET for this. Here I'll explain how I made this crosshair using GIMP.

  • Create a new image with 20x20 px
  • Make the background transparent by right clicking the image under Layers, click on "Add Alpha Channel". Mark your image and press the Delete button to make it transparent
  • Use the pencil and pick pixel as a brush or use ellipse tool if you want to make a dot
  • Draw your crosshair however you like it


Either you make sure there’s no space between the crosshair and background OR make sure the crosshair is in the middle of the background so that it has an even width and length, otherwise it will stretch and look weird later. The bigger the background is compared to the drawn crosshair, the smaller it will look at the end results.

Generally it doesn’t matter that much what size the crosshair is, it can be adjusted later on, however it’s best if it’s not too big or too small.

When it's done click on File > Export As and save it as a PNG file.

Make the folders
Create a folder and call it however you like it, for this guide I called it "crosshairtest".
In order for this to functionally make it into an addon (VPK), it has to mimic the directory of the game's default folders, which for a crosshair needs to be these two folders; materials and scripts. These two folders will be inside your main folder, in my case being "crosshairtest".









Inside the materials folder, create a new folder called vgui, and inside vgui create another new folder called hud; materials > vgui > hud
The hud folder will contain two files, Valve Material File (VMF) and Valve Texture File (VTF).









VTF is the texture format where the crosshair that was designed earlier can be displayed in the game, for it to be displayed in-game it needs to be converted from the PNG into a VTF.

VMF is a text file that will contain information about the crosshair, define its properties and the 2D-surface so that the game will have something to refer to when it loads the texture aka the crosshair that was designed.

In summary we need to make these two files in order for the crosshair that originally was a PNG to be displayed in the game. How to make these will be explained in the next sections.



Now that the materials folder is done, it's time to make the scripts folder. So go back to the start of your main folder, which in my case is "crosshairtest" and create a new folder there, name it "scripts". The scripts folder will contain the following:







This is the RES file of hudlayout. It can be retrieved from steamapps > common > Left 4 Dead 2 > left4dead2.
  • Find pak01_dir and open it with GCFScape
  • Click on scripts
  • Look for hudlayout.res there and drag it into your own scripts folder
The hudlayout.res that is now in your own folder needs to have a section added for the custom crosshair. Open it with Notepad++, lower the “overview” section by pressing enter twice to make room for this text:
Crosshair { "ControlName" "ImagePanel" "fieldName" "Crosshair" "xpos" "c-4" "ypos" "c-4" "zpos" "-10" "wide" "8" "tall" "8" "visible" "1" "enabled" "1" "image" "hud/crosshair" "scaleImage" "1" }

Click on the "save" icon or press ctrl + s. It should look like this:

















The digits in "xpos", "ypos", "wide", and "tall" can be changed later if you need to change positions or change the size of the crosshair, depending on how you originally designed the crosshair.
Make the VMF
To make a VMF:
  • Open VTFEdit
  • Click on File > New
  • Remove whatever is written there, copy the following text and paste it there
UnlitGeneric { $basetexture "vgui\hud\crosshair" $translucent 1 $ignorez 1 $vertexcolor 1 $vertexalpha 1 }
  • Click on "Save As" and save it as a VMF in the hud folder at materials > vgui > hud
  • Name it crosshair
Make the VTF
To convert the crosshair from a PNG-file into a VTF and put it together with the VMF that was made earlier:

  • Open VTFEdit
  • Click on File > Import
  • Select your PNG crosshair
  • Use the settings that I've shared below (not a must but it's what I use)
  • Click on "Save As" and save it as a VTF in the hud folder at materials > vgui > hud
  • Name it crosshair

These are the settings I use:

If you make a dot, I recommend using Sharpen Soft as a sharpen filter. If you make a cross/plus then it's better to use Sharpen Strong since it will be straight lines and not a circle.
Make the VPK
Final step is to convert all of this into an addon (VPK). In order to find the VPK application go to
steamapps > common > Left 4 Dead 2 > bin.

Make a shortcut of it to your desktop. Drag your finished folder, my case being "crosshairtest" and drop it into the VPK application, a VPK file will be generated somewhere in your desktop. Now this VPK can be added to your addons folder at
steamapps > common > Left 4 Dead 2 > left4dead2 > addons.
Note that it has to be in the addons folder and not inside the workshop folder.

Adjustments
If the crosshair's size needs to be adjusted, go to your original folder before it’s converted into a VPK, go to scripts and open up hudlayout.res with Notepad++.

Under the section “crosshair” that was added, the size can be changed with the numbers next to “wide” and “tall”. The greater the number is the bigger the crosshair will be and vice versa. If you change the numbers there make sure both "wide" and "tall" of them have the same value. This is also where you can change the placement of the crosshair with “xpos” and “ypos”, where "xpos" determines if the crosshair goes right and left and "ypos" up and down. These values don't have to be the same unless the designed crosshair wasn't centered.

Examples:
"xpos" "c-4" changed into "c-7" will make the crosshair move more to the left.
or
"xpos" "c-4" changed into "c-2" will make the crosshair move more to the right.

"ypos" "c-4" changed into "c-7" will make the crosshair move more down.
or
"ypos" "c-4" changed into "c-2" will make the crosshair move more up.

Don't forget to click on save after you do these changes.
How to integrate the crosshair into an existing HUD

If you are using a HUD from the workshop and the crosshair is not showing up, then an easy fix is to integrate the crosshair into the HUD. For this part you need the following software;
- GCFScape
- Notepad++

and the following crosshair files;
- Crosshair VMF
- Crosshair VTF
- Crosshair "script" from its hudlayout.res

1. On steam, go to LIBRARY, right-click on Left 4 Dead 2 and select Manage > Browse local files.

2. Navigate to the workshop folder and find your HUD in there.

3. Open the HUD (which is a vpk-file).

4. Drag the root folder onto your desktop.

5. Open the root folder and click on scripts, open hudlayout.res. Paste the crosshair script into hudlayout.res, save and close down.

6. Go back to root and click on materials, navigate to vgui > hud

7. Paste your crosshair VMT and VTF files into hud.

8. Last part is to rename the root file into whatever the HUD name is, drag it into vpk.exe (see "Make the VPK" chapter on where to find vpk.exe) to make it into an addon, place your customized HUD in steamapps > common > Left 4 Dead 2 > left4dead2 > addons


Now you have integrated your crosshair with the HUD.

This works with any crosshair addon from the workshop, all you have to do is to subscribe to the crosshair, launch Left 4 Dead 2 to then find the addon in the workshop folder. From its VPK file you can find the VMF/VTF/hudlayout script.
Final Results
To disable the default crosshair type in console;
crosshair 0
or
cl_crosshair_alpha 0

This is what the crosshair looks like in-game:


This is what it looks like with a laser:










Thank you for reading this guide, I hope it was helpful.


27 Comments
Rico Heart 25 Jul @ 12:53am 
From https://developer.valvesoftware.com/wiki/VTFEdit

Deprecated: The creator of VTFEdit has abandoned his projects and website, If you encounter bugs please try using the unofficially updated version (VTFEdit Reloaded).
Rico Heart 25 Jul @ 12:47am 
From https://developer.valvesoftware.com/wiki/GCFScape

Deprecated: The creator of GCFScape has abandoned his projects and website, If you encounter bugs please consider using a newer maintained alternative like VPKEdit.
Heb  [author] 21 Apr @ 2:33pm 
On versus? I don't think it works to have custom crosshair for versus mode
alsiva 21 Apr @ 11:35am 
Is there a way to make this work for infected ?
Heb  [author] 30 Apr, 2024 @ 8:19am 
you're welcome! Glad I could be of help :D
dimilftrescu 30 Apr, 2024 @ 7:53am 
Duuuude! Thanks so much for the tutorial. I can finally use my favorite HUD with my preferred crosshair. Thank you!!!
Heb  [author] 24 Apr, 2024 @ 12:23am 
thank you 🧡
Maplestrike 23 Apr, 2024 @ 5:03pm 
great guide :D
Teeheehee14 26 May, 2023 @ 4:08pm 
): thanks for responding anyway
Heb  [author] 26 May, 2023 @ 3:45pm 
that's sadly not possible