Garry's Mod

Garry's Mod

34 ratings
[TTT] Weapon Quick-Swap
   
Award
Favorite
Favorited
Unfavorite
Content Type: Addon
Addon Type: Server content
File Size
Posted
Updated
3.278 KB
13 Feb, 2022 @ 6:08am
19 Feb, 2022 @ 5:26am
2 Change Notes ( view )

Subscribe to download
[TTT] Weapon Quick-Swap

Description
Description:
A small quality of life addon that lets you pick up weapons by pressing a button. Instead of walking to groups of weapons hoping that the game gives you the one you want, just press the +use key and pick it up.

How does this work?
  • Look at the weapon you want to pick up and press the +use key (the E button by default)
  • You will automatically drop the weapon in the same slot as the new one
  • If the swapped weapons share the same ammo type, you will keep the ammo in your reserve
  • Grenades can be exchanged too, just like weapons
  • The regular way of picking weapons up by walking near them will still work
  • There's a little cooldown added between swaps, to avoid spamming



Performance:
No extra calculations will be done in the background as this addon's code will only run when releasing the +use key while aiming at a weapon entity that's close to the player. Since the relevant code is only run server side, there will be no performance hit for clients at all.



Addon compatibility:
As its name implies, this addon only works with the Trouble in Terrorist Town gamemode. The main functionality is added to the 'weapon_base' entity, so any weapon that inherits from it will gain the ability to be picked up with the +use key.



Translations:
The only text in this addon are chat messages sent to a player if the swap fails. At the moment, only english and italian languages are supported.



Enjoy!
8 Comments
ValsdalV  [author] 28 Jun, 2024 @ 5:03am 
There's multiple ones already, like for example 'Manual Weapon Pickup' by Sofisaur.

I had to limit this addon to TTT only just because there already was at least that one for the other gamemodes
BonegraVE 27 Jun, 2024 @ 10:54pm 
Someone need to make this addon for sandbox.
ValsdalV  [author] 17 Mar, 2023 @ 2:32pm 
That's odd, I made sure this addon doesn't load when the active gamemode is not TTT. In fact, it works by using functions that are only defined in TTT, so it must be something else that's letting you swap weapons
⸸ₓナイトメアₓ⸸ 17 Mar, 2023 @ 12:20pm 
oh nono i mean i somehow had this just work in sandbox, i didnt enter the files or anything. although i dont know why this worked
ValsdalV  [author] 17 Mar, 2023 @ 11:02am 
If you already extracted the code of this addon from the .gma file to make it work for sandbox, then instead of making the player drop the weapon

[code]Player:DropWeapon(Weapon)[/code]

just remove that gun:

[code]
if IsValid(Weapon) then
Weapon:Remove()
end
[/code]
⸸ₓナイトメアₓ⸸ 17 Mar, 2023 @ 3:58am 
i see where your coming from, you dont have to. it was just a thought because i somehow got this to work for sandbox andi was messing around with friends and over a good 20 minutes or so the game started to lagg because the weapons kept piling on top of each other
ValsdalV  [author] 16 Mar, 2023 @ 10:36am 
Something like that can potentially ruin the game for other players, for example running around the map using it to delete weapons before anyone else has a chance to pick them up.

I guess it can be nice to have when playing with friends, I'll see what I can do
⸸ₓナイトメアₓ⸸ 13 Mar, 2023 @ 4:51pm 
is there a way to have a swapped weapon disappear forever? like in cod zombies for example, swapped weapons are gone for good