A SetCrosshair

From ZDoom Wiki
Jump to navigation Jump to search

Weapon

action void A_SetCrosshair (int number)

Usage

Sets or disables a custom crosshair for the currently selected weapon.

You can use this function to set a specific crosshair for the currently-selected weapon, or change the current crosshair based on zoom factor or other conditions. The last crosshair set will be saved to the current weapon and reset if the player switches back to it at a later time.

Both the default crosshairs present in GZDoom.pk3 and custom crosshairs can be set with this function.

To disable the crosshair:

  • In GZDoom 4.12+: pass -1 for number.
  • In earlier versions: include an empty graphic for your custom crosshair and use this function to set the weapon to use that crosshair.

Note that the player may override the custom crosshair by setting the crosshairforce CVAR to true.

Parameters

  • int number
The crosshair number to use. A value of 0 resets the crosshair to the player's default selection.
(New from 4.12) A value of -1 will disable the crosshair.

Examples

Nuvolachalk.png Note: This article lists no examples. If you make use of this feature in your own project(s) or know of any basic examples that could be shared, please add them. This will make it easier to understand for future authors seeking assistance. Your contributions are greatly appreciated.