ulx.motdmenu_exists = true
-- DON'T EDIT THAT
local isUrl
local url
-- MOTD BUTTON SETUP
local MainURL = "http://fickschnitzel.weebly.com/regeln.html" --Main Motd URL Website, I REALLY recommend to run the motd by url.
local MotdText = "Willkommen!" --Motd Main Windows Tittle.
local AcceptButtonText = "Werbung überspringen (5)" --Text for Accept rules button
local AcceptButtonTime = 5 --accept rules button will appear only after "X" seconds.
local AcceptSay = "" --Say in chat "X" message when I clic on accept rules button.
local DeclineButton = true --Spawn Decline Button ?
local DeclineButtonText = "Kick mich" --Text for Decline rules button
local DeclineSay = "Kich mich." --Say in chat "X" message when I clic on decline rules button.
local DeclineKickTime = 5 --time to kick the player if he decline rules, don't put so low, the script need to run "DeclineSay" before.
local WebButtonText = "Öffne Web Menü" --Text to open the Web Menu
local CloseWebButtonText = "Schließe Web Menü" --Text to close the Web Menu
local ReturnButtonText = "Startseite" --Text for Return on Main URL Page button.
local CloseMotdButtonText = "Schließe MOTD Seite" --Text for Close Motd Page button.
--Website Setup
local Website1ButtonText = "Google" --Text for 1st Website button.
local Website2ButtonText = "Youtube" --Text for 2nd Website button.
local Website3ButtonText = "Gmod.org" --Text for 3nd Website button.
local Website4ButtonText = "FacePunch" --Text for 4nd Website button.
local Website1URL = "http://www.google.com/" --1st Webstie URL
local Website2URL = "http://www.youtube.com/" --2nd Website URL
local Website3URL = "http://www.garrysmod.org/" --3nd Website URL
local Website4URL = "http://www.facepunch.com/" --4nd Website URL
--------------------------------------------------------------------------------------
-------DON'T EDIT ANYTHING BELLOW, if you know what you do, it's your choice !--------
--------------------------------------------------------------------------------------
function ulx.showMotdMenu()
--creating main windows
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( MotdText )
window:SetVisible( true )
window:MakePopup()
--creating windows for html
local html = vgui.Create( "HTML", window )
--AcceptButton
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", AcceptSay)
end
window:Close()
gui.EnableScreenClicker(false) -- Disable the mouse
end
AcceptButton:SetSize( 90, 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.5, window:GetTall() - AcceptButton:GetTall() - 10 )
else
AcceptButton:SetPos( ( window:GetWide() / 4.0 ) - ( AcceptButton:GetWide() / 2 ), window:GetTall() - 57 )
--DeclineButton
local DeclineButton = vgui.Create( "DButton", window )
DeclineButton:SetSize( 110, 40 )
DeclineButton:SetPos( ( window:GetWide() / 3.0 ) - ( DeclineButton:GetWide() / 2 ), window:GetTall() - 57 )
if DeclineButtonText == "" then
DeclineButton:SetText( "Decline" )
else
DeclineButton:SetText( DeclineButtonText )
end
DeclineButton:SetVisible( true )
DeclineButton.DoClick = function()
if DeclineSay != "" then
RunConsoleCommand("say", DeclineSay)
window:Close()
end
if DeclineKickTime > 0 then
timer.Simple( DeclineKickTime, function()
RunConsoleCommand( "disconnect" )
end )
end
end
end
--CloseMotd page Button
local CloseMotdButton = vgui.Create( "DButton", window )
CloseMotdButton:SetSize( 110, 40 )
CloseMotdButton:SetPos( ( window:GetWide() / 1.1 ) - ( CloseMotdButton:GetWide() / 2 ), window:GetTall() - 57 )
if CloseMotdButtonText == "" then
CloseMotdButton:SetText( "Return" )
else
CloseMotdButton:SetText( CloseMotdButtonText )
end
CloseMotdButton:SetVisible( true )
CloseMotdButton:SetDisabled( true )
CloseMotdButton.DoClick = function()
window:Close()
end
--Return on main page Button
local ReturnButton = vgui.Create( "DButton", window )
ReturnButton:SetSize( 100, 40 )
ReturnButton:SetPos( ( window:GetWide() / 1.6 ) - ( ReturnButton:GetWide() / 2 ), window:GetTall() - 57 )
if ReturnButtonText == "" then
ReturnButton:SetText( "Return" )
else
ReturnButton:SetText( ReturnButtonText )
end
ReturnButton:SetVisible( false )
ReturnButton.DoClick = function()
html:OpenURL( MainURL )
CloseMotdButton:SetDisabled( false )
end
--Website1 Button
local Website1Button = vgui.Create( "DButton", window )
Website1Button:SetSize( 100, 40 )
Website1Button:SetPos( ( window:GetWide() / 1.4 ) - ( Website1Button:GetWide() / 2 ), window:GetTall() - 45 )
if Website1ButtonText == "" then
Website1Button:SetText( "Website1" )
else
Website1Button:SetText( Website1ButtonText )
end
Website1Button:SetVisible( false )
Website1Button.DoClick = function()
html:OpenURL( Website1URL )
CloseMotdButton:SetDisabled( false )
end
--Website2 Button
local Website2Button = vgui.Create( "DButton", window )
Website2Button:SetSize( 100, 40 )
Website2Button:SetPos( ( window:GetWide() / 1.4 ) - ( Website2Button:GetWide() / 2 ), window:GetTall() - 90 )
if Website2ButtonText == "" then
Website2Button:SetText( "Website2" )
else
Website2Button:SetText( Website2ButtonText )
end
Website2Button:SetVisible( false )
Website2Button.DoClick = function()
html:OpenURL( Website2URL )
CloseMotdButton:SetDisabled( false )
end
--Website3 Button
local Website3Button = vgui.Create( "DButton", window )
Website3Button:SetSize( 100, 40 )
Website3Button:SetPos( ( window:GetWide() / 1.25 ) - ( Website3Button:GetWide() / 2 ), window:GetTall() - 45 )
if Website3ButtonText == "" then
Website3Button:SetText( "Website3" )
else
Website3Button:SetText( Website3ButtonText )
end
Website3Button:SetVisible( false )
Website3Button.DoClick = function()
html:OpenURL( Website3URL )
CloseMotdButton:SetDisabled( false )
end
--Website4 Button
local Website4Button = vgui.Create( "DButton", window )
Website4Button:SetSize( 100, 40 )
Website4Button:SetPos( ( window:GetWide() / 1.25 ) - ( Website4Button:GetWide() / 2 ), window:GetTall() - 90 )
if Website4ButtonText == "" then
Website4Button:SetText( "Website4" )
else
Website4Button:SetText( Website4ButtonText )
end
Website4Button:SetVisible( false )
Website4Button.DoClick = function()
html:OpenURL( Website4URL )
CloseMotdButton:SetDisabled( false )
end
--Open WebButton
local CloseWebButton = vgui.Create( "DButton", window )
local WebButton = vgui.Create( "DButton", window )
WebButton:SetSize( 100, 40 )
WebButton:SetPos( ( window:GetWide() / 1.25 ) - ( WebButton:GetWide() / 2 ), window:GetTall() - 57 )
if WebButtonText == "" then
WebButton:SetText( "OpenWebMenu" )
else
WebButton:SetText( WebButtonText )
end
WebButton:SetVisible( true )
WebButton:SetDisabled( false )
WebButton.DoClick = function()
--WebButton Clic
html:SetSize( window:GetWide() - 20, window:GetTall() - AcceptButton:GetTall() - 90 )
WebButton:SetPos( ( window:GetWide() / 1.9 ) - ( WebButton:GetWide() / 2 ), window:GetTall() - 90 )
WebButton:SetDisabled( true )
CloseWebButton:SetVisible( true )
ReturnButton:SetVisible( true )
Website1Button:SetVisible( true )
Website2Button:SetVisible( true )
Website3Button:SetVisible( true )
Website4Button:SetVisible( true )
CloseMotdButton:SetDisabled( false )
end
--CloseWebButton
CloseWebButton:SetSize( 100, 40 )
CloseWebButton:SetPos( ( window:GetWide() / 1.9 ) - ( WebButton:GetWide() / 2 ), window:GetTall() - 45 )
if CloseWebButtonText == "" then
CloseWebButton:SetText( "CloseWebMenu" )
else
CloseWebButton:SetText( CloseWebButtonText )
end
CloseWebButton:SetVisible( false )
CloseWebButton.DoClick = function()
--CloseWebButton Clic
html:SetSize( window:GetWide() - 20, window:GetTall() - AcceptButton:GetTall() - 50 )
WebButton:SetPos( ( window:GetWide() / 1.25 ) - ( WebButton:GetWide() / 2 ), window:GetTall() - 57 )
WebButton:SetDisabled( false )
CloseWebButton:SetVisible( false )
ReturnButton:SetVisible( false )
Website1Button:SetVisible( false )
Website2Button:SetVisible( false )
Website3Button:SetVisible( false )
Website4Button:SetVisible( false )
CloseMotdButton:SetDisabled( false )
end
--windows for button
html:SetSize( window:GetWide() - 20, window:GetTall() - AcceptButton:GetTall() - 50 )
html:SetPos( 10, 30 )
--if motd got an url, that will run the url, if false this will run motd.txt
if not isUrl then
html:SetHTML( file.Read( "ulx/motd.txt" ) )
else
html:OpenURL( url )
end
end
--find url
function ulx.rcvMotd( isUrl_, text )
isUrl = isUrl_
if not isUrl then
file.Write( "ulx/motd.txt", text )
else
if text:find( "://", 1, true ) then
url = text
else
url = "http://" .. text
end
end
end