From 4ab6312ab13a21ceead5bd9959f8b1cdff3cef43 Mon Sep 17 00:00:00 2001 From: Fesiug Date: Sat, 9 Dec 2023 22:47:27 -0500 Subject: [PATCH] Perfected weapon switching, I think --- .../benny/gamemode/modules/player/sh_hud.lua | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/gamemodes/benny/gamemode/modules/player/sh_hud.lua b/gamemodes/benny/gamemode/modules/player/sh_hud.lua index a2e16aa..93b0c7e 100644 --- a/gamemodes/benny/gamemode/modules/player/sh_hud.lua +++ b/gamemodes/benny/gamemode/modules/player/sh_hud.lua @@ -33,12 +33,28 @@ local function beatup( ply, num ) -- If we are selected our currently equipped weapon, holster it. return wep:D_SetReqID( hand, "" ) else - if id == wep:D_GetID( !hand ) then - -- If the wanted weapon is in the other hand, request to holster it. - wep:D_SetReqID( !hand, "" ) - end - if wep:D_GetID( !hand ) != "" and wep:D_GetID( hand ) != "" then -- If we have something in this hand, swap it with the other - wep:D_SetReqID( !hand, wep:D_GetID( hand ) ) + if wep:D_GetReqID( hand ) != "" then + -- Something is in this hand + + if wep:D_GetReqID( !hand ) != "" then + -- Something in the other hand + wep:D_SetReqID( !hand, wep:D_GetReqID( hand ) ) + wep:D_SetReqID( hand, id ) + return + else + -- Nothing in the other hand + wep:D_SetReqID( !hand, "" ) + wep:D_SetReqID( hand, id ) + return + end + else + -- Nothing in this hand. + if wep:D_GetReqID( !hand ) == id then + -- Weapon we want is in the other hand. + wep:D_SetReqID( !hand, "" ) + wep:D_SetReqID( hand, id ) + return + end end return wep:D_SetReqID( hand, id ) end