Class_menu addon to work with DarkRP HUD job title

Hi all, I was wondering if anyone here could help me with a small issue. I’ve been using this addon http://www.garrysmod.org/downloads/?a=view&id=52077 as a character loadout when you first join my server and when you do select the job/character the DarkRP job title does not change to the specified character in the addon.

Here is lua script:

[lua]class = {}

–add classes like below, copy & paste and rename the class
class[“ExampleClass”] = {}
class[“ExampleClass”].Weapons ={
“weapon_m4”,
“weapon_ar2”
}
–add as many as you need, remember the comma after each weapon, except the last one

–you can leave any of these below variables out
class[“ExampleClass”].Ammo = {}
class[“ExampleClass”].Ammo.weapon_m4_primary = 60
class[“ExampleClass”].Ammo.weapon_ar2_primary = 90
class[“ExampleClass”].Ammo.weapon_ar2_secondary = 5
–add in the ammo like so, if you don’t include the ammo it’ll just give you the default amount
–adding in secondary ammo for a weapon that doesn’t take it might screw it up, i wouldn’t suggest trying it
class[“ExampleClass”].Speed = {}
class[“ExampleClass”].Speed.Walk = 250–default is 125 for walk
class[“ExampleClass”].Speed.Run = 550-- 275 for run
class[“ExampleClass”].Health = 200
class[“ExampleClass”].Model = “models/player/Group03/male_09.mdl”
class[“ExampleClass”].Desc = “A description of your class.
This is optional”

if (SERVER) then
AddCSLuaFile(“client/classmenu_cl.lua”)
AddCSLuaFile(“Classes.lua”)
function ChangeClass(ply,com,arg)
local name = tostring(arg[1])
if !class[name] then return end
if ply.InitialSpawn then
ply.Class = name
ply:StripWeapons()
ChangeClass2(ply)
ply.InitialSpawn = false
else
//change class and die
ply.Class = name
ply:KillSilent()
end
end
concommand.Add("_Changeclass", ChangeClass)

function FirstSpawn( ply )
ply:SendLua(“ClassMenuShow()”)
ply.InitialSpawn = true
ply.Class = nil
end
hook.Add( “PlayerInitialSpawn”, “playerInitialSpawn”, FirstSpawn );

function Loadout( ply )
ChangeClass2(ply)
return true // this prevents the gamemode’s default PlayerLoadout from getting called (this only applies when you’re not coding the gamemode itself)
end
hook.Add( “PlayerLoadout”, “gravAndShot”, Loadout)

function ChangeClass2(ply)
local name = ply.Class
if ply.Class and class[name] then
for i,v in pairs(class[name].Weapons) do
//weapon
ply:Give(v)
//ammo
if class[name].Ammo then
if class[name].Ammo[v…"_primary"] then
ply:SetAmmo(class[name].Ammo[v…"_primary"],ply:GetWeapon(v):GetPrimaryAmmoType( ))
end
if class[name].Ammo[v…"_secondary"] then
ply:SetAmmo(class[name].Ammo[v…"_secondary"],ply:GetWeapon(v):GetSecondaryAmmoType( ))
end
end
end
//playermodel
if class[name].Model then
timer.Simple(0.1,function() ply:SetModel(class[name].Model) end)
end
//health
if class[name].Health then
ply:SetMaxHealth(class[name].Health)
ply:SetHealth(class[name].Health)
end
//speed
if class[name].Speed then
timer.Simple(0.1,function() GAMEMODE:SetPlayerSpeed(ply, class[name].Speed.Walk, class[name].Speed.Run) end)
end

end	

end

end
if (CLIENT) then

function GetString(name)
local hstr;local sstr
if class[name].Health then
hstr = "Health: “…class[name].Health…”
"
else
hstr = “”
end
if class[name].Speed then
sstr = "Walk Speed: “…class[name].Speed.Walk…”
"
sstr = sstr…"Run Speed: “…class[name].Speed.Run…”
"
else
sstr = “”
end
local wstr = “Weapons:
"
//if !class[name] then return str end
for p,o in pairs(class[name].Weapons) do
wstr = wstr…o…”
"
end
local str = hstr…sstr…wstr
return str
end
function ClassMenuShow()
local classname = “nothing”
local w,h = ScrW()/2, ScrH()/2
local Frame = vgui.Create( “DFrame” ); //Create a frame
local icon = vgui.Create( “DModelPanel”, Frame )
Frame:SetSize(w+15,h );
Frame:SetPos( 100, 100 ); //Move the frame to 100,100
Frame:SetVisible( true ); //Make the frame
Frame:MakePopup( ); //Visible
Frame:SetTitle(“Choose your class” ); //Set the title to “This is the title”
function Frame:Paint()
draw.RoundedBox( 8, 0,0,w+15,h, Color(56,56,56,240) )
surface.SetDrawColor( 75,75,75,200 )
surface.DrawLine( 0,20,w,20)
draw.RoundedBox( 8, 30+(w/4)+w/3, 26, w/3, h/2 - 35, Color(50,50,75,200) )
draw.RoundedBox( 8, 30+(w/4)+w/3, h/2 - 4, w/3, h/2 - 40, Color(50,50,75,200) )
end
local List = vgui.Create(“DPanelList”, Frame)
List:EnableHorizontal(false) // disable horizontal scroll
List:EnableVerticalScrollbar(true) // enable vertical scroll
local myLabel= vgui.Create(“DLabel”, Frame)
myLabel:SetPos(38+(w/4)+w/3, 30)
myLabel:SetText("Weapons:
")
myLabel:SizeToContents()
local myLabel2= vgui.Create(“DLabel”, Frame)
myLabel2:SetPos(38+(w/4)+w/3, h/2)
myLabel2:SetText("Description:
")
myLabel2:SizeToContents()

function icon.LayoutEntity( icon, me )  
icon.RunAnimation( icon ) 
end 
icon:SetPos(25+(w/4)-(w/4-w/6), w/8 + 20)
icon:SetSize(w/2,w/2)
icon:SetCamPos( Vector( 40, 0, 50 ) ) 
icon:SetLookAt( Vector( 0, 0, 50 ) ) 
icon:SetFOV( 90 ) 
	
for i,v in pairs(class) do
	local Button = vgui.Create( "DButton", Frame ); //Create a button that is attached to Frame 
	Button:SetText( i ); //Set the button's text to "Click me!" 
	List:AddItem(Button)
	function Button:DoClick( ) //This is called when the button is clicked 
		myLabel:SetText(GetString(i))  
		local desc = class*.Desc or ""
		myLabel2:SetText("Description:

"…desc)
timer.Simple(0.1, function() myLabel:SizeToContents() end)
timer.Simple(0.1, function() myLabel2:SizeToContents() end)
classname = i
if class*.Model then
icon:SetModel( class*.Model )
else
icon:SetModel( LocalPlayer():GetModel() )
end
end

end
List:SetSize(w/4,h-40-40)
List:SetPos(30,30)	
local Button2 = vgui.Create( "DButton", Frame ); //Create a button that is attached to Frame 
Button2:SetText( "Choose Class" ); //Set the button's text to "Click me!" 
Button2:SetSize(w/4-40,20)
Button2:SetPos(50,h-40)
function Button2:DoClick()
	RunConsoleCommand("_ChangeClass", classname)
	Frame:SetVisible(false)
end

function ChatTextClassMenu( playerindex, playername, text )  
	if LocalPlayer() == player.GetByID(playerindex) then  	
	if text == "/changeclass" then
		if Frame:IsValid() then
			Frame:SetVisible(true)
		else
			ClassMenuShow()
		end
	end
	end
end  // Hook the event.  
hook.Add( "ChatText", "ChatTextClassMenu", ChatTextClassMenu );  

end
end[/lua]

Thank’s for that. :slight_smile:

[noparse][lua][/lua][/noparse] tags are going to get you more help :wink:

That is the whole script.

What, he ment that you should put [noparse][lua]LOLCODEHERE[/lua][/noparse] in your OP, for the code to be 99 times easier to read.