Derma Help.

So, im making a menu for donators, all i need to know is, how do i make a list of buttons were their function is to change their model with this command but enters the players name with out them typing anything so the command will worki.e


 local DermaButton = vgui.Create( "DButton" )	
DermaButton:SetParent( DermaPanel )			
DermaButton:SetText( "Wear a grey suit" )				
DermaButton:SetPos( 25, 50 )					
DermaButton:SetSize( 250, 30 )				
DermaButton.DoClick = function()			 
	RunConsoleCommand( ulx model <playersname> models/greysuit.mdl )			
end 

How do i make it get the players name?

and how do i have a list of these in order is it just this:




local DermaButton = vgui.Create( "DButton" )	
DermaButton:SetParent( DermaPanel )			
DermaButton:SetText( "Wear a grey suit" )				
DermaButton:SetPos( 25, 50 )					
DermaButton:SetSize( 250, 30 )				
DermaButton.DoClick = function()			 
	RunConsoleCommand( ulx model <playersname> models/greysuit.mdl )	

local DermaButton = vgui.Create( "DButton" )	
DermaButton:SetParent( DermaPanel )			
DermaButton:SetText( "Wear a grey suit" )				
DermaButton:SetPos( 25, 50 )					
DermaButton:SetSize( 250, 30 )				
DermaButton.DoClick = function()			 
	RunConsoleCommand( ulx model <playersname> models/bluesuit.mdl )	


local DermaButton = vgui.Create( "DButton" )	
DermaButton:SetParent( DermaPanel )			
DermaButton:SetText( "Wear a grey suit" )				
DermaButton:SetPos( 25, 50 )					
DermaButton:SetSize( 250, 30 )				
DermaButton.DoClick = function()			 
	RunConsoleCommand( ulx model <playersname> models/greensuit.mdl )	



But change the DermaButton on each one to a unique name? thanks!

Net Library

Write the model from the button and send the net message to the server and check if they’re a VIP.
Also insert the model to a serverside table to prevent exploitation
Do something like this:



--SERVERSIDE--
util.AddNetworkString("ANY_NAME")
local Allowed_Models = {"models/whatever.mdl"} <---make a list of models allowed to prevent abuse 

net.Receive("ANY_NAME",function(_,ply)
if !ply:IsUserGroup("Your_VIP_Group") then return end
local model = net.ReadString()
if !table.HasValue(Allowed_Models,model) then return end
ply:SetModel(model)
end)
------------------

------------------
--CLIENTSIDE

button.DoClick = function(me)
net.Start("ANY_NAME")
net.WriteString("Model dir here")
net.SendToServer()
end

------------------



Server


 

util.AddNetworkString("clothesMenu")
local Allowed_Models = {"models/player/suits/male_02_open.mdl", "models/player/suits/male_02_open_tie.mdl", "models/player/suits/male_02_open_waistcoat.mdl", "models/player/suits/male_02_shirt.mdl"} <---make a list of models allowed to prevent abuse 

net.Receive("clothesMenu",function(_,ply)
if !ply:IsUserGroup("donator") or ply:IsAdmin() then return end
local model = net.ReadString()
if !table.HasValue(Allowed_Models,model) then return end
ply:SetModel(model)
end)



Client




local Clothes = vgui.Create( "DFrame" )
Clothes:SetPos( 5, 5 )
Clothes:SetSize( 1060, 640 )
Clothes:SetTitle( "Clothes Menu" )
Clothes:SetVisible( true )
Clothes:SetDraggable( true )
Clothes:ShowCloseButton( true )
Clothes:MakePopup()
Clothes.Paint = function( self, w, h ) 
	draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 200 ) )

hook.Add( "PlayerBindPress", "F4", function(client, bind, pressed)
bind = bind:lower()
print("binding")

if (bind:find("gm_showhelp") and pressed) then
elseif (bind:find("gm_showspare1") and pressed) then
    elseif (bind:find("gm_showspare2") and pressed) then
CreatePanel()
    end
end)



local clothe = vgui.Create( "DButton", Frame )
clothe:SetText( "Click me I'm pretty!" )
clothe:SetTextColor( Color( 255, 255, 255 ) )
clothe:SetPos( 100, 100 )
clothe:SetSize( 100, 30 )
clothe.Paint = function( self, w, h )
	draw.RoundedBox( 0, 0, 0, w, h, Color( 41, 128, 185, 250 ) )
end


clothe.DoClick = function(me)
net.Start("clothesMenu")
net.WriteString("models/player/suits/male_02_closed_tie.mdl")
net.SendToServer()
end


?

RunConsoleCommand() requires a string.

So why does my new code not work?

Your DoClick’s don’t have an end, and the console command isn’t right.
I think they need end’s, well I think…



local DermaButton = vgui.Create( "DButton" )	
DermaButton:SetParent( DermaPanel )			
DermaButton:SetText( "Wear a grey suit" )				
DermaButton:SetPos( 25, 50 )					
DermaButton:SetSize( 250, 30 )				
DermaButton.DoClick = function()			 
	RunConsoleCommand( ulx model <playersname> models/greysuit.mdl )	
end

local DermaButton = vgui.Create( "DButton" )	
DermaButton:SetParent( DermaPanel )			
DermaButton:SetText( "Wear a grey suit" )				
DermaButton:SetPos( 25, 50 )					
DermaButton:SetSize( 250, 30 )				
DermaButton.DoClick = function()			 
	RunConsoleCommand( ulx model <playersname> models/bluesuit.mdl )
end


local DermaButton = vgui.Create( "DButton" )	
DermaButton:SetParent( DermaPanel )			
DermaButton:SetText( "Wear a grey suit" )				
DermaButton:SetPos( 25, 50 )					
DermaButton:SetSize( 250, 30 )				
DermaButton.DoClick = function()			 
	RunConsoleCommand( ulx model <playersname> models/greensuit.mdl )
end


To whoever rated my post dumb:

Im talking about this code…

if !ply:IsUserGroup(“donator”) or ply:IsAdmin() then return end needs a ! at ply:isadmin too


 util.AddNetworkString("clothesMenu")
local Allowed_Models = {"models/player/suits/male_02_open.mdl", "models/player/suits/male_02_open_tie.mdl", "models/player/suits/male_02_open_waistcoat.mdl", "models/player/suits/male_02_shirt.mdl"} <---make a list of models allowed to prevent abuse 

net.Receive("clothesMenu",function(_,ply)
if !ply:IsUserGroup("donator") or !ply:IsAdmin() then return end
local model = net.ReadString()
if !table.HasValue(Allowed_Models,model) then return end
ply:SetModel(model)
end)


??

Are there any errors returned from this code?

Will test it now

[editline]27th February 2016[/editline]

Nope, no console errors and no menu opens.

No menu opens?



hook.Add( "PlayerBindPress", "F4", function(client, bind, pressed)
bind = bind:lower()
print("binding")

if (bind:find("gm_showhelp") and pressed) then
elseif (bind:find("gm_showspare1") and pressed) then
    elseif (bind:find("gm_showspare2") and pressed) then
CreatePanel()
    end
end)


wat



hook.Add( "PlayerBindPress", "F4", function(client, bind, pressed)

	bind = bind:lower()


	if (bind:find("gm_showhelp") and pressed) then

		CreatePanel()

	elseif (bind:find("gm_showspare1") and pressed) then
    	
    	CreatePanel()

   	elseif (bind:find("gm_showspare2") and pressed) then

		CreatePanel()

    end

end)


with that i get


 [ERROR] addons/clothes/lua/autorun/cl_clothes.lua:49: 'end' expected (to close 'function' at line 9) near '<eof>'
  1. unknown - addons/clothes/lua/autorun/cl_clothes.lua:0


[editline]27th February 2016[/editline]

Ok now i fixed that i get this


 
[ERROR] addons/clothes/lua/autorun/cl_clothes.lua:24: attempt to call global 'CreatePanel' (a nil value)
  1. fn - addons/clothes/lua/autorun/cl_clothes.lua:24
   2. unknown - addons/ulib/lua/ulib/shared/hook.lua:105



What is CreatePanel? I don’t see it defined in the code you provided us.

Oh yea thanks!