Benny/gamemodes/benny/gamemode/modules/player/sh_hud.lua

46 lines
957 B
Lua
Raw Normal View History

2023-12-08 00:30:31 -05:00
-- Predicted weapon switching
local dads = {
[KEY_1] = 1,
[KEY_2] = 2,
[KEY_3] = 3,
[KEY_4] = 4,
[KEY_5] = 5,
[KEY_6] = 6,
[KEY_7] = 7,
[KEY_8] = 8,
[KEY_9] = 9,
[KEY_0] = 0,
}
local function beatup( ply, num )
local weighted = ply:INV_Weight()
local inv = ply:INV_Get()
local iflip = table.Flip( inv )
local invid = 0
for _, item in pairs( weighted ) do
local class = WeaponGet(item.Class)
if class.Features == "firearm" or class.Features == "grenade" then
invid = invid + 1
if num == invid then
--RunConsoleCommand( "benny_inv_equip", iflip[item], "false", "false" )
if ply:KeyDown(IN_ZOOM) then
2023-12-08 01:04:36 -05:00
return ply:SetReqID2(iflip[item])
2023-12-08 00:30:31 -05:00
else
2023-12-08 01:04:36 -05:00
return ply:SetReqID1(iflip[item])
2023-12-08 00:30:31 -05:00
end
end
end
end
2023-12-08 01:04:36 -05:00
return ply:SetReqID1( "" )
2023-12-08 00:30:31 -05:00
end
hook.Add( "PlayerButtonDown", "Benny_PlayerButtonDown_Inv", function( ply, button )
local wep = ply:BennyCheck()
if dads[button] then
beatup( ply, dads[button] )
end
end)