General > Developers Corner
how do i make the ulx motd open up with tabs?
Vilusia:
Hey would it be possible if you could make one with 3 tabs?
I tried doing it myself but I'm new to lua and I'm still learning. Derma is not my strong point :P
Thanks.
MrPresident:
Sure, give me time, I'm at work right now. What do you want the 3 tabs to be? What URLs do you want them to point to?
Vilusia:
Forum
www.vnbgameservers.net
Donate
http://www.vnbgameservers.net/misc.php?action=payments
Rules
http://www.vnbgameservers.net/thread-58.html
Thanks for doing this. I will study your code so I can better myself in the future. :)
MrPresident:
Make sure your ULX and ULib are up to date with the most recent SVN and then replace this file:
replace all the code in this file with
addons/ULX/lua/ulx/modules/cl/motdmenu.lua
--- Code: ---ulx.motdmenu_exists = true
local isUrl
local url
function ulx.showMotdMenu()
local url1 = "www.vnbgameservers.net"
local url2 = "http://www.vnbgameservers.net/misc.php?action=payments"
local url3 = "http://www.vnbgameservers.net/thread-58.html"
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( "ULX MOTD" )
window:SetVisible( true )
window:MakePopup()
local tabmenu = vgui.Create( "DPropertySheet", window )
local html1 = vgui.Create( "HTML" )
local html2 = vgui.Create( "HTML" )
local html3 = vgui.Create( "HTML" )
local button = vgui.Create( "DButton", window )
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 )
html3:SetSize( window:GetWide() - 30, window:GetTall() - button:GetTall() - 70 )
html3:SetPos( 15, 50 )
html3:OpenURL( url3 )
tabmenu:AddSheet( "Forum", html1, _, false, false, _)
tabmenu:AddSheet( "Donate", html2, _, false, false, _)
tabmenu:AddSheet( "Rules", html3, _, 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
--- End code ---
Vilusia:
Thanks so much! You are amazing!
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version