Rank up system w/ weapon loadout?

Ok well I’ve managed to make a ranking system and as of now it works by how many kills you have acquired since you joined the server for the very 1st time, and based on that it gives you a rank…each rank unlocks different weapons and as of now it forces those weapons on you depending on your rank.

Well what I want to eventually do is make a gui(or whatever its called) in which you can switch between any of your previously acquired weapons, then once i have that make another one for a secondary weapon (Pistol…ect) Starting to sound like CoDMW2? Well thats because thats where i got the idea from…anyways…

My question is how would i go about making a Gui for changing between said weapons. I’ve never worked with gui or whatever its called so, can someone maybe point me in the right direction?

Come’on guys…anyone want to help me here? This is just the last thing i need.

Read, learn, copy, adapt, and credit.

Oh! - and this might help.

-merp-

He’s asking about GUI, VGUI, Derma etc. He already has the rank system coded.

Here, I made you a simple block of VGUI code which you can umsg or concommand hook to test.

[lua]function DrawGunMenu( )

-- Make a simple frame
local frame = vgui.Create( "DFrame" )
frame:SetSize( 256, 512 )
frame:Center( )
frame:MakePopup( true )

-- Make a panel list to store our player's weapons
local dplist1 = vgui.Create( "DPanelList", frame )
dplist1:StretchToParent( 5, 25, 5, 5 )
dplist1:Center( )
dplist1:EnableHorizontal( false )

-- For every weapon the player has...
for k, v in pairs( LocalPlayer( ):GetWeapons( ) ) do

	-- Make a button for it
	local button1 = vgui.Create( "DButton" )
	button1:SetSize( 256, 64 )
	button1:SetText( v:GetPrintName( ) )
	
	-- Add it to our list
	dplist1:AddItem( button1 )

end

end
[/lua]

Untested, but its fairly simple. You can use weapons.GetList( ) instead of LocalPlayer( ):GetWeapons( ) to make a button for all the weapons available on the server.

Thanks Zcom, I read up on it some more an managed to figure out how to get it to pop up on joining and getting it to work with F1.

But i need a way that it will take away all weapons except the one you press, and I’ve been trying to think of a way to do this but cannot come up with one short of making a button for every weapon…which even if i do that i’d still have to check rank.

Actually, it’s easier than it sounds. By using a for loop, you’re letting the language do the repetitive work for you. Also, you can add functions to Derma buttons that are run when they are clicked. In this function you can check for rank levels, or add the weapons you click on to a separate table. (That would be displayed in another menu, for example.), and basically anything that you can do in a regular function.

This is a modified version of the for loop I posted earlier:
[lua] – For every weapon the player has…
for k, v in pairs( LocalPlayer( ):GetWeapons( ) ) do

	-- Make a button for it
	local button1 = vgui.Create( "DButton" )
	button1:SetSize( 256, 64 )
	button1:SetText( v:GetPrintName( ) )
	
	-- Anything in here will be run when the  button is clicked
	button1.DoClick = function( )
	
		-- Check for rank here. Example:
		if ( LocalPlayer( ):Rank( ) != 1 ) then return; end
	
		-- Print the data that we have available
		local print_name = button1:GetValue( )
		print( print_name, k, v )
	
	end
	
	-- Add it to our list
	dplist1:AddItem( button1 )

end

[/lua]

But what you’re asking for is basically:

1.) A menu that displays all the weapons available to the player
2.) Each weapon displayed as a click-able button
3.) The player can only choose 1 weapon, after clicking the one he wants: all others are grayed out (Probably until the next rank is obtained etc.)

If you give me a few more details I’ll be glad to help you out. Right now it doesn’t sound like you’re doing anything outside of your level of expertise :wink: