ulx.motdmenu_exists = true
local isUrl
local url
function accept(button)
if time == 1 then
button:SetText("1 second remaining")
else
button:SetText(string.format("%i more seconds", time))
end
if time == 0 then
button:SetText("I Agree")
button:SetDisabled( false )
end
time = time - 1
end
function ulx.showMotdMenu()
local window = vgui.Create( "DFrame" )
if ScrW() > 640 then -- Make it larger if we can.
window:SetSize( ScrW()*0.9, ScrH()*0.9 )
else
window:SetSize( 640, 480 )
end
window:Center()
window:SetTitle( "Benders Villa" )
window:ShowCloseButton( false ) -- Show the close button?
window:SetVisible( true )
window:MakePopup()
local panel = vgui.Create( "DPanel", window )
local html = vgui.Create( "HTML", panel )
local button = vgui.Create( "DButton", window )
button:SetText( "10 seconds remaining" )
button.DoClick = function()
window:Close();
timer.Create("chat1", 1, 1, function() RunConsoleCommand("say", "I have read and agree to the rules listed in the motd.") end)
timer.Create("chat2", 2, 1, function() RunConsoleCommand("say_team", "I have read and agree to the rules listed in the motd.") end)
end
button:SetSize( 100, 40 )
button:SetDisabled( true )
button:SetPos( (window:GetWide() - button:GetWide()) / 3, window:GetTall() - button:GetTall() - 10 )
local buttoncancel = vgui.Create( "DButton", window )
buttoncancel:SetText( "I Disagree" )
buttoncancel.DoClick = function()
timer.Create("leave", 1, 1, function() RunConsoleCommand("disconnect") end)
end
buttoncancel:SetSize( 100, 40 )
buttoncancel:SetPos( (window:GetWide() - buttoncancel:GetWide()) / 1.5, window:GetTall() - buttoncancel:GetTall() - 10 )
panel:SetSize( window:GetWide() - 20, window:GetTall() - button:GetTall() - 50 )
panel:SetPos( 10, 30 )
html:Dock( FILL )
time = 10
timer.Create("accepttimer", 1, 1, function() accept( window ) end)
if( not ValidPanel( button ) )then return end
if not isUrl then
html:SetHTML( file.Read( "ulx/motd.txt" ) )
else
html:OpenURL( url )
end
end