• How to run a derma when typing a command ingame?
    5 replies, posted
I created a derma panel today and I want it that the mayor can type in chat !wanted ( not /wanted ) to open the derma menu? How does it work pls help. Here is my code: [Lua] DOAP = vgui.Create( "DFrame" ) DOAP:SetSize( 1000, 500 ) DOAP:SetText( "" ) DOAP:Center() DOAP:SetTitle("") DOAP:SetVisible( true ) DOAP:SetDraggable( false ) DOAP:ShowCloseButton( false ) DOAP:MakePopup() DOAP.Paint = function(s, w, h) draw.RoundedBox(5, 0, 0, w, h, Color(0,0,0)) draw.RoundedBox(5, 2, 2, w-4, h-4, Color(50, 50, 50)) end local DOAT2 = vgui.Create( "DLabel" , DOAP ) DOAT2:SetPos( 465, 20 ) DOAT2:SetText( "Dead or Alive" ) DOAT2:SetSize(200, 20) local DOAB = vgui.Create( "DButton" , DOAP ) DOAB:SetPos( 977, 3) DOAB:SetText( "X" ) DOAB:SetSize( 20, 20 ) DOAB:SetTextColor( Color(255,255,255)) DOAB.Paint = function(s, w, h) draw.RoundedBox(3,0,0,w,h,Color(255, 50, 50)) end DOAB.DoClick = function() DOAP:Close() end local DOAC = vgui.Create( "DComboBox" , DOAP ) DOAC:SetPos( 400, 150 ) DOAC:SetSize( 200, 20 ) DOAC:SetValue( "Player" ) for k, v in pairs( player.GetAll() ) do DOAC:AddChoice ( tostring( v:Name() ) ) end local DOAT = vgui.Create( "DLabel" , DOAP ) DOAT:SetPos( 460, 35 ) DOAT:SetText( "Wanted menu" ) DOAT:SetSize(200,200) local DOAB2 = vgui.Create( "DButton" , DOAP ) DOAB2:SetPos( 390, 180) DOAB2:SetText( "Wanted" ) DOAB2:SetSize( 100, 20 ) DOAB2:SetTextColor( Color(255,255,255)) DOAB2.Paint = function(s, w, h) draw.RoundedBox(3,0,0,w,h,Color(255, 50, 50)) end DOAB2.DoClick = function() end local DOAB3 = vgui.Create( "DButton" , DOAP ) DOAB3:SetPos( 510, 180) DOAB3:SetText( "Unwanted" ) DOAB3:SetTextColor(Color(255,255,255)) DOAB3:SetSize( 100, 20 ) DOAB3:SetTextColor( Color(255,255,255)) DOAB3.Paint = function(s, w, h) draw.RoundedBox(3,0,0,w,h,Color(50, 180, 50)) end DOAB3.DoClick = function() end DOACH = vgui.Create("DCheckBox", DOAP) DOACH:SetPos(495,250) DOACH:Toggle() function DOACH:OnChange( bVal ) if ( bVal ) then DOACH2:SetValue() DOACH3:SetValue() end end DOACH2 = vgui.Create("DCheckBox", DOAP) DOACH2:SetPos(145,250) function DOACH2:OnChange( bVal ) if ( bVal ) then DOACH:SetValue() DOACH3:SetValue() end end DOACH3 = vgui.Create("DCheckBox", DOAP) DOACH3:SetPos(845,250) function DOACH3:OnChange( bVal ) if ( bVal ) then DOACH2:SetValue() DOACH:SetValue() end end local DOAT3 = vgui.Create( "DLabel" , DOAP ) DOAT3:SetPos( 140, 230 ) DOAT3:SetText( "Dead" ) DOAT3:SetSize(200, 20) local DOAT4 = vgui.Create( "DLabel" , DOAP ) DOAT4:SetPos(475, 230) DOAT4:SetText( "Dead or Alive" ) DOAT4:SetSize(200, 20) local DOAT5 = vgui.Create( "DLabel" , DOAP ) DOAT5:SetPos( 840, 230 ) DOAT5:SetText( "Alive" ) DOAT5:SetSize(200, 20) local DOATEXTE = vgui.Create( "DTextEntry", DOAP ) DOATEXTE:SetPos( 410, 360 ) DOATEXTE:SetSize( 200, 20 ) DOATEXTE:SetText( "" ) DOATEXTE.OnEnter = function( self ) chat.AddText( self:GetValue() ) end local DOATEXTE2 = vgui.Create( "DTextEntry", DOAP ) DOATEXTE2:SetPos( 410, 420 ) DOATEXTE2:SetSize( 200, 20 ) DOATEXTE2:SetText( "" ) DOATEXTE2.OnEnter = function( self ) chat.AddText( self:GetValue() ) end local DOAT6 = vgui.Create( "DLabel" , DOAP ) DOAT6:SetPos( 485, 340 ) DOAT6:SetText( "Price dead" ) DOAT6:SetSize(200, 20) local DOAT7 = vgui.Create( "DLabel" , DOAP ) DOAT7:SetPos( 485, 400 ) DOAT7:SetText( "Price alive" ) DOAT7:SetSize(200, 20) [/Lua]
net library [url]https://wiki.garrysmod.com/page/Net_Library_Usage[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/OnPlayerChat]GM/OnPlayerChat[/url] Edit: or net library, I guess. Whatever works for you.
[QUOTE=Neat-Nit;50016462][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/OnPlayerChat]GM/OnPlayerChat[/url] Edit: or net library, I guess. Whatever works for you.[/QUOTE] How you make it open the panel ? [editline]27th March 2016[/editline] With OnPlayerChat
[QUOTE=Athods;50016802]How you make it open the panel ? [editline]27th March 2016[/editline] With OnPlayerChat[/QUOTE] [CODE] hook.Add( 'OnPlayerChat', 'OpenWantedDerma', function( ply, txt, team, dead ) if ply == LocalPlayer() and txt == "!wanted" then -- YOUR DERMA STUFF HERE end end ) [/CODE]
[QUOTE=MPan1;50017925][CODE] hook.Add( 'OnPlayerChat', 'OpenWantedDerma', function( ply, txt, team, dead ) if ply == LocalPlayer() and txt == "!wanted" then -- YOUR DERMA STUFF HERE end end ) [/CODE][/QUOTE] Didnt work
Sorry, you need to Log In to post a reply to this thread.