tmp64 / BugfixedHL-Rebased

Bugfixed and improved Half-Life
GNU General Public License v3.0
112 stars 25 forks source link

Add _toggleweapon command #233

Open rtxa opened 3 months ago

rtxa commented 3 months ago

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:

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:

tmp64 commented 2 months ago

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.

rtxa commented 2 months ago

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.