BugfixedHL-Rebased icon indicating copy to clipboard operation
BugfixedHL-Rebased copied to clipboard

Add _toggleweapon command

Open rtxa opened this issue 1 year ago • 2 comments

The _toggleweapon command allows the player to quickly switch to a specific weapon if it is available in their inventory. If the requested weapon is not available, the command will switch to a default weapon specified.

Usage

_toggleweapon <weapon_name> <default_weapon>

Where:

  • <weapon_name>: The primary weapon the player wants to switch to, if available.
  • <default_weapon>: The default weapon to switch to if <weapon_name> is not available.

Example

bind q "_toggleweapon weapon_shotgun weapon_crowbar"

In this example, if you press Q, the command will first try to switch to the shotgun (weapon_shotgun). If the shotgun is not available in the player's inventory, it will switch to the crowbar (weapon_crowbar) as the default weapon.

Benefits:

  • Provides a fallback option if the primary weapon is not available, ensuring the player always has a suitable weapon.
    • For players who have all the weapons binded to the keyboard (which can be quite a few), the _toggleweapon command can help reduce the number of key bindings needed, making weapon switching more efficient and also having a nearby key for faster switching.

rtxa avatar Jul 20 '24 19:07 rtxa

bind q "weapon_crowbar;weapon_shotgun" seems to do the same. It first switches to the crowbar and immediately switches to the shotgun. If the shotgun isn't available, the crowbar stays as the active weapon.

tmp64 avatar Aug 10 '24 03:08 tmp64

True, but you have to wait to the server to answer those commands to do the switching, it's faster if you check it from client-side if the gun is available for better response and send one command instead of two. Besides I've already test that before and it's slower.

rtxa avatar Aug 10 '24 16:08 rtxa