Reposted from [URL="http://facepunch.com/threads/1172645?p=35283096"]http://facepunch.com/threads/1172645?p=35283096[/URL]
Anyways I am trying to make a ULX MOTD that has a button, for instance when a player joins the player will not be able to exit out of the MOTD until 10 seconds have passed.(to give him enough time to atleast see there are rules) How would I add buttons? How would I add timers to them? Heres what I have so far.
[CODE] <html>
<head>
<meta HTTP-EQUIV="REFRESH" content="0; url=motdurl">
</head>
</html>
]]
local html = vgui.Create( "HTML", window )
local AcceptButton = vgui.Create( "DButton", window )
if AcceptButtonText == "" then
AcceptButton:SetText( "Close" )
else
AcceptButton:SetText( AcceptButtonText )
end
AcceptButton.DoClick = function()
if AcceptSay != "" then
RunConsoleCommand("say", I accept the server rules)
end
window:Close()
gui.EnableScreenClicker(false) -- Disable the mouse
end
AcceptButton:SetSize( 100, 40 )
if AcceptButtonTime > 0 then
AcceptButton:SetDisabled( true )
timer.Simple( AcceptButtonTime, function()
AcceptButton:SetDisabled( false )
end )
end
if !DeclineButton then
AcceptButton:SetPos( (window:GetWide() - AcceptButton:GetWide()) / 2, window:GetTall() - AcceptButton:GetTall() - 10 )
else
AcceptButton:SetPos( ( window:GetWide() / 2.3 ) - ( AcceptButton:GetWide() / 2 ), window:GetTall() - 57 )
local DeclineButton = vgui.Create( "DButton", window )
DeclineButton:SetSize( 100, 40 )
DeclineButton:SetPos( ( window:GetWide() / 1.7 ) - ( DeclineButton:GetWide() / 2 ), window:GetTall() - 57 )
if DeclineButtonText == "" then
DeclineButton:SetText( "Decline" )
else
DeclineButton:SetText( DeclineButtonText )
end
DeclineButton:SetVisible( true )
DeclineButton.DoClick = function()
RunConsoleCommand("say", I am an idiot who can not comprehend rules. I wunder what disconnect does?)
RunConsoleCommand( "disconnect" )
end
end[/CODE]
1. The second arguments for RCC is a string, so surround them with "
2. You could just move the DoClick function into a timer.Simple function
[lua]timer.Simple(10, function()
AcceptButton.DoClick() = function()
Main:Close() --Replace Main with your DFrame var
RunConsoleCommand("say", "I accept the server rules.")
end
end)[/lua]
Unrelated to your question, but a 10 second wait would piss me off more than it would make me read the motd. If I were you, I'd just use one of those things that displays while you're connecting to the server as an motd. Players are going to spend at least 10 seconds connecting and loading everything, so it would be perfect.
But yeah I don't give a shit if it's the best server out there, if there was some dumb 10 second wait to close the motd I probably would not go there.
[QUOTE=Hyper Iguana;35297896]1. The second arguments for RCC is a string, so surround them with "
2. You could just move the DoClick function into a timer.Simple function
[lua]timer.Simple(10, function()
AcceptButton.DoClick() = function()
Main:Close() --Replace Main with your DFrame var
RunConsoleCommand("say", "I accept the server rules.")
end
end)[/lua][/QUOTE]
Thanks, when I get home I'll try it....
Sorry, you need to Log In to post a reply to this thread.