I'm creating a "ForceMOTD" command, however I do not want players to be able to close it instantly.
I looked at the motdmenu.lua file (or whatever it's called), however I'm not sure if copying the file would work.
If I changed
local isUrl
local url
function ulx.showMotdMenu( steamid )
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 html = vgui.Create( "DHTML", window )
--html:SetAllowLua( true ) -- Too much of a security risk for us to enable. Feel free to uncomment if you know what you're doing.
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 )
html:SetSize( window:GetWide() - 20, window:GetTall() - button:GetTall() - 50 )
html:SetPos( 10, 30 )
if not isUrl then
html:SetHTML( ULib.fileRead( "data/ulx_motd.txt" ) or "" )
else
url = string.gsub( url, "%%curmap%%", game.GetMap() )
url = string.gsub( url, "%%steamid%%", steamid )
html:OpenURL( url )
end
end
to
local isUrl
local url
function ulx.showMotdMenu( steamid )
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 html = vgui.Create( "DHTML", window )
--html:SetAllowLua( true ) -- Too much of a security risk for us to enable. Feel free to uncomment if you know what you're doing.
timer.Simple(60, function()
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 )
end)
html:SetSize( window:GetWide() - 20, window:GetTall() - button:GetTall() - 50 )
html:SetPos( 10, 30 )
if not isUrl then
html:SetHTML( ULib.fileRead( "data/ulx_motd.txt" ) or "" )
else
url = string.gsub( url, "%%curmap%%", game.GetMap() )
url = string.gsub( url, "%%steamid%%", steamid )
html:OpenURL( url )
end
end
Would that work?
I'm not talking about the function name, just wondering if the motd would actually appear + would the timer on the close button work.
Thanks. I would test but at school.
EDIT: Just realised, even if I called this, it would open on the calling player. How would I make it open on the target_ply?