• Derma Menu - Change class to default class(citizen) when this button is pressed
    1 replies, posted
Not sure what I'm doing. Basically, the 2nd button should change the players class to the default class which is citizen if pressed. It's not giving me the output I want. This is for darkrp. Code: [lua] function MyCoolMenu() local Frame = vgui.Create( "DFrame" ) Frame:SetTitle( "Make a person a cop" ) Frame:SetSize( 300, 500 ) Frame:Center() Frame:MakePopup() local Button = vgui.Create( "DButton", Frame ) Button:SetText( "test1" ) Button:SetTextColor( Color( 255, 255, 255 ) ) Button:SetPos( 100, 50 ) Button:SetSize( 100, 30 ) Button.Paint = function( self, w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 41, 128, 185, 250 ) ) -- Draw a blue button end Button.DoClick = function( ply, team ) ply:changeTeam(GAMEMODE.DefaultTeam, true) end local Button = vgui.Create( "DButton", Frame ) Button:SetText( "test2" ) Button:SetTextColor( Color( 255, 255, 255 ) ) Button:SetPos( 100, 100 ) Button:SetSize( 100, 30 ) Button.Paint = function( self, w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 41, 128, 185, 250 ) ) -- Draw a blue button end Button.DoClick = function(ply) ply:changeTeam(GAMEMODE.DefaultTeam, true) end end concommand.Add( "open_coolmenu", MyCoolMenu ) [/lua] Console Error: [lua] [ERROR] gamemodes/darkrp/gamemode/cl_init.lua:56: attempt to call method 'changeTeam' (a nil value) 1. DoClick - gamemodes/darkrp/gamemode/cl_init.lua:56 2. unknown - lua/vgui/dlabel.lua:218 [/lua]
ChangeTeam is probably a serverside only function, whereas derma menus are clientside - look into using the net library
Sorry, you need to Log In to post a reply to this thread.