Single-file Crosshair plugin, which draws a five-dot crosshair on the HUD whose gap widens with the distance to what the player is aiming at.

The PreDrawCrosshair, AdjustCrosshairColor and AdjustCrosshairGap hooks can hide or restyle it; the plugin's own implementations hide it when the enable_crosshair config is false and highlight nearby players and cw_item entities.

Backported from the Flux project.

Summary

Hooks

Called to pick the crosshair color; uses the information color when aiming at a nearby player or item.
Called to pick the crosshair gap; keeps it at 8 when aiming at a nearby player or item.
Called when the HUD is painted; draws a five-dot crosshair whose gap widens with the aimed distance.
Called before the crosshair is drawn; hides it when the enable_crosshair config is false.

Hooks

PLUGIN:AdjustCrosshairColor(trace, distance)

client gamemodes/catwork/plugins/cl_crosshair.lua:57

Implements hook AdjustCrosshairColor

Called to pick the crosshair color; uses the information color when aiming at a nearby player or item.

Parameters

  • trace Map The local player's eye trace
  • distance Number Distance from the player to the trace hit position

Returns

  • Color The crosshair color within 600 units of a player or cw_item, otherwise nil

PLUGIN:AdjustCrosshairGap(trace, distance)

client gamemodes/catwork/plugins/cl_crosshair.lua:70

Implements hook AdjustCrosshairGap

Called to pick the crosshair gap; keeps it at 8 when aiming at a nearby player or item.

Parameters

  • trace Map The local player's eye trace
  • distance Number Distance from the player to the trace hit position

Returns

  • Number The gap in pixels within 600 units of a player or cw_item, otherwise nil

Called when the HUD is painted; draws a five-dot crosshair whose gap widens with the aimed distance.

Nothing is drawn when the PreDrawCrosshair hook returns true. The AdjustCrosshairColor and AdjustCrosshairGap hooks, called with the eye trace and its distance, can override the color and the gap; the gap eases towards its target each frame.

PLUGIN:PreDrawCrosshair()

client gamemodes/catwork/plugins/cl_crosshair.lua:81

Implements hook PreDrawCrosshair

Called before the crosshair is drawn; hides it when the enable_crosshair config is false.

Returns

  • Boolean True to skip drawing the crosshair, otherwise nil

Defined in