Weapon Selector replaces the default weapon selection HUD with a scrolling list of the
player's weapons.
The invprev, invnext and slot binds move the highlight, and attack selects the highlighted
weapon through the selectweapon console command. The selector closes after five seconds
without input. Plugins can keep it from reacting with the ShouldOpenWepselect hook and
follow it through OnWeaponIndexChange and OnWeaponSelected.
Summary
Hooks
Methods
Hooks
Draws the weapon selector while it is open and animates its entries scrolling toward the highlighted weapon.
Hides the default weapon selection HUD.
Parameters
- element String name of the HUD element
Returns
- Boolean false for 'CHudWeaponSelection', nil otherwise
Implements hook OnWeaponIndexChange
Opens the weapon selector and starts scrolling it from the old index to the new one.
Parameters
- old_index Number previously highlighted index in the player's weapon list
- index Number newly highlighted index
Implements hook OnWeaponSelected
Closes the weapon selector and clears its entries once a weapon has been selected.
Parameters
- _index Number index of the selected weapon in the player's weapon list
Handles the weapon selection binds: invprev, invnext and slot binds move the highlight, attack selects the highlighted weapon while the selector is open. Ignored in vehicles, while attack is held and when ShouldOpenWepselect returns false.
Parameters
- client Player
- bind String the bind's command
- pressed Boolean whether the bind was pressed rather than released
Returns
- Boolean true if the bind was consumed, nil otherwise
Fades the weapon selector in while it is in use, and fades it out and closes it after five seconds without input.
Methods
Builds the five selector entries (two above and two below) around a weapon index. Each entry is a table with the fields weapon, scale, x, y and highlight.
Parameters
- index Number index in the local player's weapon list; wraps around
- tab Boolean optional, defaults to
falsereturn the entries instead of storing them in self.display
Returns
- List<Map> the entries if tab is set, nil otherwise