Garry's Mod

Garry's Mod

39 个评价
[TTT] Weapon Quick-Swap
   
奖励
收藏
已收藏
取消收藏
素材类型: 插件
插件类型: 服务器内容
文件大小
发表于
更新日期
5.736 KB
2022 年 2 月 13 日 上午 6:08
8 月 28 日 上午 5:56
3 项改动说明 ( 查看 )

订阅以下载
[TTT] Weapon Quick-Swap

描述
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 条留言
ValsdalV  [作者] 7 月 23 日 上午 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 7 月 23 日 上午 5:04 
do you think you could add a convar for swapping with the same weapon type?
ValsdalV  [作者] 2024 年 6 月 28 日 上午 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 2024 年 6 月 27 日 下午 10:54 
Someone need to make this addon for sandbox.
ValsdalV  [作者] 2023 年 3 月 17 日 下午 2: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
Bnuymare 2023 年 3 月 17 日 下午 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  [作者] 2023 年 3 月 17 日 上午 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]
Bnuymare 2023 年 3 月 17 日 上午 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  [作者] 2023 年 3 月 16 日 上午 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
Bnuymare 2023 年 3 月 13 日 下午 4:51 
is there a way to have a swapped weapon disappear forever? like in cod zombies for example, swapped weapons are gone for good