Holstering fixes, don't equip both of same wep!

This commit is contained in:
Fesiug 2023-12-09 00:28:25 -05:00
parent ee326c4919
commit 76d6f63350
3 changed files with 20 additions and 17 deletions

View File

@ -153,7 +153,7 @@ function SWEP:BHolster( hand )
end end
local p = self:GetOwner() local p = self:GetOwner()
B_Sound( self, "Common.Holster" ) --B_Sound( self, "Common.Holster" )
local item = self:BTable( hand ) local item = self:BTable( hand )
if item then if item then
local class = WeaponGet(item.Class) local class = WeaponGet(item.Class)

View File

@ -198,6 +198,8 @@ end)
function SWEP:BStartHolster( hand ) function SWEP:BStartHolster( hand )
if self:D_GetHolstering( hand ) == -1 then if self:D_GetHolstering( hand ) == -1 then
B_Sound( self, "Common.Holster" )
-- print( "Holstering the " .. (hand and "LEFT" or "RIGHT") )
self:D_SetHolstering( hand, 1 ) self:D_SetHolstering( hand, 1 )
end end
end end
@ -225,14 +227,21 @@ function SWEP:Think()
for i=1, 2 do for i=1, 2 do
local hand = i==2 local hand = i==2
local req = self:D_GetReqID( hand ) local req = self:D_GetReqID( hand )
local req_o = self:D_GetReqID( !hand )
local curr = self:D_GetID( hand ) local curr = self:D_GetID( hand )
local curr_o = self:D_GetID( !hand )
if req != curr then if req != curr then
if curr != "" then if curr != "" then
-- require holster first -- require holster first
self:BStartHolster( hand ) self:BStartHolster( hand )
else else
local otherhasthis = curr_o == req
if req != "" and inv[req] then if req != "" and inv[req] then
if otherhasthis then
self:BStartHolster( !hand )
else
self:BDeploy( hand, req ) self:BDeploy( hand, req )
end
else else
self:BStartHolster( hand ) self:BStartHolster( hand )
end end

View File

@ -19,6 +19,7 @@ local function beatup( ply, num )
local inv = ply:INV_Get() local inv = ply:INV_Get()
local wep = ply:BennyCheck() local wep = ply:BennyCheck()
local iflip = table.Flip( inv ) local iflip = table.Flip( inv )
local hand = ply:KeyDown(IN_ZOOM)
local invid = 0 local invid = 0
for _, item in pairs( weighted ) do for _, item in pairs( weighted ) do
@ -28,27 +29,20 @@ local function beatup( ply, num )
invid = invid + 1 invid = invid + 1
if num == 0 then num = 10 end if num == 0 then num = 10 end
if num == invid then if num == invid then
if ply:KeyDown(IN_ZOOM) then if id == wep:D_GetID( hand ) then
if id == wep:D_GetID( true ) then -- If we are selected our currently equipped weapon, holster it.
return ply:SetReqID2("") return wep:D_SetReqID( hand, "" )
else else
return ply:SetReqID2(id) 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 end
else return wep:D_SetReqID( hand, id )
if id == wep:D_GetID( false ) then
return ply:SetReqID1("")
else
return ply:SetReqID1(id)
end end
end end
end end
end end
end return wep:D_SetReqID( hand, "" )
if ply:KeyDown(IN_ZOOM) then
return ply:SetReqID2( "" )
else
return ply:SetReqID1( "" )
end
end end
hook.Add( "PlayerButtonDown", "Benny_PlayerButtonDown_Inv", function( ply, button ) hook.Add( "PlayerButtonDown", "Benny_PlayerButtonDown_Inv", function( ply, button )