2024-03-07 21:19:30 -05:00
|
|
|
|
2024-10-08 20:46:36 -04:00
|
|
|
local Emeta = FindMetaTable("Entity")
|
|
|
|
|
|
|
|
local qt2 = {
|
|
|
|
["slot1"] = 1,
|
|
|
|
["slot2"] = 2,
|
|
|
|
["slot3"] = 3,
|
|
|
|
["slot4"] = 4,
|
|
|
|
["slot5"] = 5,
|
|
|
|
["slot6"] = 6,
|
|
|
|
["slot7"] = 7,
|
|
|
|
["slot8"] = 8,
|
|
|
|
["slot9"] = 9,
|
|
|
|
["slot0"] = 0,
|
|
|
|
}
|
|
|
|
local qt = {
|
|
|
|
["invprev"] = -1,
|
|
|
|
["invnext"] = 1,
|
|
|
|
}
|
|
|
|
|
|
|
|
hook.Add( "PlayerBindPress", "Benny_PlayerBindPress_Original", function( ply, bind, pressed, code )
|
|
|
|
if qt2[bind] then
|
|
|
|
local Num = qt2[bind]
|
|
|
|
if pressed then
|
|
|
|
local inv = ply:GetInventory():GetWeighted()
|
|
|
|
local wep = ply:HandlerCheck()
|
|
|
|
local invf = table.Flip( inv )
|
|
|
|
|
|
|
|
local NumOfActive = 0
|
|
|
|
NumOfActive = invf[wep:GetDesireR()]
|
|
|
|
|
|
|
|
if Num == NumOfActive then
|
|
|
|
Num = 0
|
2024-03-07 21:19:30 -05:00
|
|
|
end
|
2024-10-08 20:46:36 -04:00
|
|
|
input.SelectWeapon( ply:GetWeapon("goat_"..Num) )
|
2024-03-07 21:19:30 -05:00
|
|
|
end
|
2024-10-08 20:46:36 -04:00
|
|
|
return true
|
2024-03-07 21:19:30 -05:00
|
|
|
end
|
2024-10-08 20:46:36 -04:00
|
|
|
if qt[bind] then
|
|
|
|
if pressed then
|
|
|
|
local Num = 0
|
|
|
|
|
|
|
|
local inv = ply:GetInventory():GetWeighted()
|
|
|
|
local wep = ply:HandlerCheck()
|
|
|
|
local invf = table.Flip( inv )
|
|
|
|
local invc = #inv
|
|
|
|
|
|
|
|
Num = wep:GetDesireR() and invf[wep:GetDesireR()] or 0
|
|
|
|
Num = Num + qt[bind]
|
|
|
|
|
|
|
|
if Num > invc then
|
|
|
|
Num = 0
|
|
|
|
elseif Num < 0 then
|
|
|
|
Num = invc
|
2024-09-20 16:20:22 -04:00
|
|
|
end
|
2024-10-08 20:46:36 -04:00
|
|
|
|
|
|
|
input.SelectWeapon( ply:GetWeapon("goat_"..Num) )
|
2024-09-20 16:20:22 -04:00
|
|
|
end
|
2024-10-08 20:46:36 -04:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
end)
|
2024-03-07 21:19:30 -05:00
|
|
|
|
2024-09-20 16:20:22 -04:00
|
|
|
hook.Add( "PlayerSwitchWeapon", "Benny_PlayerSwitchWeapon_Goat", function( ply, old, ent )
|
|
|
|
if ent.BennyItemHandler then return true end -- what happened?
|
2024-03-12 18:43:31 -04:00
|
|
|
local wep = ply:HandlerCheck()
|
2024-09-20 16:20:22 -04:00
|
|
|
if !wep then print("PlayerSwitchWeapon Benny Handler Missing!!") return false end
|
|
|
|
if ent:IsValid() and ent.Goat then
|
|
|
|
local inv = ply:GetInventory():GetWeighted()
|
2024-03-07 21:19:30 -05:00
|
|
|
|
2024-09-20 16:20:22 -04:00
|
|
|
if ent.Goat == 0 then wep:SetDesireR( NULL ) return false end
|
|
|
|
|
|
|
|
local ent = inv[ent.Goat]
|
|
|
|
if ent then
|
|
|
|
wep:SetDesireR( ent )
|
2024-03-07 21:19:30 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-09-20 16:20:22 -04:00
|
|
|
return false
|
2024-03-07 21:19:30 -05:00
|
|
|
end)
|
2024-09-20 16:20:22 -04:00
|
|
|
|
|
|
|
for i=0, 9 do
|
|
|
|
local tent = {}
|
|
|
|
tent.Goat = i
|
|
|
|
|
|
|
|
weapons.Register( tent, "goat_" .. i )
|
|
|
|
end
|