Reposted from http://facepunch.com/threads/1172645?p=35283096
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.
<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