So im making a report menu for my server, I have a few problems
1. Any text will open the menu
2. The derma draws over the text box so you cannot input into it
3. The button creates a lua error saying that the method i used isn't global
Here is my code, Its all clientside:
[code]
hook.Add( "OnPlayerChat", "reportadmin", function( ply, text, public )
text = string.lower( text )
if(string.sub(text,0,7) == "!report" ) then
local TextEntry = vgui.Create( "DTextEntry", frame )
TextEntry:SetPos( 25, 50 )
TextEntry:SetSize( 450, 45 )
TextEntry:Center()
TextEntry:SetText( "What's The problem!?" )
end
local Button = vgui.Create( "DButton", Frame )
Button:SetText( "Send report!" )
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 ) )
end
Button.DoClick = function()
chat.AddText("@", TEXTENTRY:GetValue() )
end
local Frame = vgui.Create( "DFrame" )
Frame:SetTitle( "Report a player to the admin!" )
Frame:SetSize( 600, 600 )
Frame:Center()
Frame:MakePopup()
Frame:SetDraggable( false )
Frame.Paint = function( self, w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 71, 76, 60, 150 ) )
end
end )
[/code]
[QUOTE=Crystalize;47766309]So im making a report menu for my server, I have a few problems
1. Any text will open the menu
2. The derma draws over the text box so you cannot input into it
3. The button creates a lua error saying that the method i used isn't global
Here is my code, Its all clientside:
[code]
hook.Add( "OnPlayerChat", "reportadmin", function( ply, text, public )
text = string.lower( text )
if(string.sub(text,0,7) == "!report" ) then
local TextEntry = vgui.Create( "DTextEntry", frame )
TextEntry:SetPos( 25, 50 )
TextEntry:SetSize( 450, 45 )
TextEntry:Center()
TextEntry:SetText( "What's The problem!?" )
end
local Button = vgui.Create( "DButton", Frame )
Button:SetText( "Send report!" )
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 ) )
end
Button.DoClick = function()
chat.AddText("@", TEXTENTRY:GetValue() )
end
local Frame = vgui.Create( "DFrame" )
Frame:SetTitle( "Report a player to the admin!" )
Frame:SetSize( 600, 600 )
Frame:Center()
Frame:MakePopup()
Frame:SetDraggable( false )
Frame.Paint = function( self, w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 71, 76, 60, 150 ) )
end
end )
[/code][/QUOTE]
Some quick observations:
Lua array indexes start at 1, not 0.
Your if statement only encompasses the first block of code which is why the rest is running every time PlayerSay is called.
Try creating the DFrame first.
Sorry, you need to Log In to post a reply to this thread.