Garry's Mod

Garry's Mod

35 betyg
[TTT] Weapon Quick-Swap
   
Utmärkelse
Favorit
Favoritmarkerad
Avfavoritmarkerad
Content Type: Addon
Addon Type: ServerContent
Filstorlek
Lades upp
Uppdaterades
5.736 KB
13 feb, 2022 @ 6:08
28 aug @ 5:56
3 ändringsnotiser ( visa )

Abonnera för att ladda ner
[TTT] Weapon Quick-Swap

Beskrivning
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!
10 kommentarer
ValsdalV  [skapare] 23 jul @ 6:17 
@SvveetMavis

It's been a few years since I touched this addon's code and so I may be wrong, but from what I remember the reason I disallowed swapping between the same weapon type (I assume you mean an M16 with another M16, for example) is that the game doesn't let you carry two identical guns at the same time, not even for the single instant this addon needs.

This will probably require a non-trivial addon rework, but I'm not opposed to that. If I ever update this, it will be to add what you ask
SvveetMavis 23 jul @ 5:04 
do you think you could add a convar for swapping with the same weapon type?
ValsdalV  [skapare] 28 jun, 2024 @ 5:03 
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 @ 22:54 
Someone need to make this addon for sandbox.
ValsdalV  [skapare] 17 mar, 2023 @ 14:32 
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:20 
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  [skapare] 17 mar, 2023 @ 11:02 
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:58 
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  [skapare] 16 mar, 2023 @ 10:36 
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 @ 16:51 
is there a way to have a swapped weapon disappear forever? like in cod zombies for example, swapped weapons are gone for good