Hello. I'm using the following MOTD code at the moment which has two tabs and a countdown to close the window.
It works fine, but the tabs are a little on the small side and thus hardly noticeable.
I've seen servers with pretty awesome ulx motd's and i'm trying to achieve just that.
Any help is appreciated.
Code:
ulx.motdmenu_exists = true
local isUrl
local url
function ulx.showMotdMenu( steamid )
local url1 = "http://thelounge.zxq.net/Lounge/loungerules.php"
local url2 = "http://thelounge.zxq.net/Lounge/Donate.php"
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( "MOTD" )
window:SetVisible( true )
window:SetDraggable( false )
window:ShowCloseButton( false )
window:MakePopup()
local tabmenu = vgui.Create( "DPropertySheet", window )
local html1 = vgui.Create( "HTML" )
local html2 = vgui.Create( "HTML" )
button = vgui.Create( "DButton", window )
button:SetSize( 100, 40 )
button:SetPos( (window:GetWide() - button:GetWide()) / 2, window:GetTall() - button:GetTall() - 10 )
button:SetText( "Wait - " )
button:SetDisabled( true )
timersec = 10 --this is how long your motd will stay open, I reccomend
--adding about 5 to your desired value to compensate for lag
timer.Create( "countDown", 1, 10, function() --change 14 to the same value as timersec
timersec = timersec - 1
button:SetText( "Wait - " .. timersec )
if timersec == 0 then
button:SetText( "Close" )
button:SetDisabled( false )
button.DoClick = function() window:Close() end
end
end)
if timersec == 0 then --all this crap may be useless, I left it in because everything was working
button:SetText( "Close" )
button:SetDisabled( false )
button.DoClick = function() window:Close() end
end
--[[
local button = vgui.Create( "DButton", window ) --original button close, above adds timer.
button:SetText( "Close" )
button.DoClick = function() window:Close() end
button:SetSize( 100, 40 )
button:SetPos( (window:GetWide() - button:GetWide()) / 2, window:GetTall() - button:GetTall() - 10 )
--]]
tabmenu:SetSize( window:GetWide() - 20, window:GetTall() - button:GetTall() - 50 )
tabmenu:SetPos( 10, 30 )
html1:SetSize( window:GetWide() - 30, window:GetTall() - button:GetTall() - 70 )
html1:SetPos( 15, 50 )
html1:OpenURL( url1 )
html2:SetSize( window:GetWide() - 30, window:GetTall() - button:GetTall() - 70 )
html2:SetPos( 15, 50 )
html2:OpenURL( url2 )
tabmenu:AddSheet( "Rules", html1, _, false, false, _)
tabmenu:AddSheet( "Donate", html2, _, false, false, _)
end
function ulx.rcvMotd( isUrl_, text )
isUrl = isUrl_
if not isUrl then
ULib.fileWrite( "data/ulx_motd.txt", text )
else
if text:find( "://", 1, true ) then
url = text
else
url = "http://" .. text
end
end
end