Do you hate CHudWeaponSelection on your server?

Hello, if you hate the default weapon selection hud on your server, then you are in the right place!

The following code will remove the default CHudWeaponSelection ui and will allow you to bind keys to use weapons, so for example on my server I wanted it removed, but players couldnt access weapons, so I used this instead.

an example is shown at the bottom of the code:



//GET RID OF SHITTY CHudWeaponSelection

local hide = {
        CHudWeaponSelection = true,
        
}

hook.Add( "HUDShouldDraw", "HideHUD", function( name )
	if ( hide[ name ] ) then return false end

	-- Don't return anything here, it may break other addons that rely on this hook.
end )

//KEY BINDER

local MultiKeyBinder = {};
MultiKeyBinder.Binds = {};

-- ########  Find, if someone presses a key @aVoN
function MultiKeyBinder.Think()
	local self = MultiKeyBinder;
	local p = LocalPlayer();
	for _,v in pairs(self.Binds) do
		local pressed = true;
		for _,key in pairs(v.Keys) do
			if(not input.IsKeyDown(key)) then
				pressed = false;
				break;
			end
		end
		if(pressed) then
			if(not v.Pressed) then
				if p:IsTyping() then
				else
					v.Pressed = true;
					p:ConCommand(v.Command);
				end
			end
		else
			v.Pressed = nil;
		end
	end 
end

hook.Add("Think","MultiKeyBinder.Think",MultiKeyBinder.Think);

-- ########  Adds a bind @aVoN
function MultiKeyBinder.AddBind(cmd,...)
	table.insert(MultiKeyBinder.Binds,
		{
			Keys = {...},
			Command = cmd,
		}
	);
end

MultiKeyBinder.AddBind("use tfa_acr",KEY_1) --EXAMPLE (FORMAT: MultiKeyBinder.AddBind("use WEAPON_CLASS",key)


for weapon_class, you would put every weapon class of any weapon a player can get. I use the number keys (1 for primary, 2 for secondary, 3 for explosives, 4 for door module and 5 for tool gun.

You MUST add the binds inside the same lua file as the code!

Place in lua\autorun\client

wrong section