Something like this (my script):
local HTML = {}
function HTML:StatusChanged( text )
end
function HTML:ProgressChanged( progress )
end
function HTML:FinishedURL( url )
end
function HTML:OpeningURL( url, target )
end
vgui.Register( "frostyDonator", HTML, "HTML" )
function frosty.showDonatorMenu()
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( "Donation Menu" )
window:SetVisible( true )
window:MakePopup()
local html = vgui.Create( "frostyDonator", window )
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 )
html:SetHTML( file.Read( "Frostymod/Donator.txt" ) )
end
usermessage.Hook( "SendDonatorMenu", frosty.showDonatorMenu )
function frosty.rcvDonatorStart( um )
frosty.DonatorContent = ""
end
usermessage.Hook( "frostyDonatorStart", frosty.rcvDonatorStart )
function frosty.rcvDonatorEnd( um )
file.Write( "frosty/Donator.txt", frosty.DonatorContent )
frosty.DonatorContent = nil
end
usermessage.Hook( "frostyDonatorEnd", frosty.rcvDonatorEnd )
function frosty.rcvDonatorText( um )
frosty.DonatorContent = frosty.DonatorContent .. um:ReadString()
end
usermessage.Hook( "frostyDonatorText", frosty.rcvDonatorText )
CreateConVar( "frostydonation_opentype", "F4", FCVAR_ARCHIVE )
local function CheckKeys()
if ( menu:IsVisible() ) then return end
// If the chat's open we don't want anything triggering when we type.
if ( chatOpen ) then
if ( frostydonation.KEY && ( frostydonation.KEY < KEY_F1 || frostydonation.KEY > KEY_F12 ) ) then return end
end
RunString( "frostydonation.KEY = KEY_" .. string.upper( GetConVarString( "frostydonation_opentype" ) ) )
if ( input.IsKeyDown( frostydonation.KEY or KEY_F4 ) ) then
RunConsoleCommand( "frostydonation" )
return
end
end
MOTD File:
local HTML = {}
function HTML:StatusChanged( text )
end
function HTML:ProgressChanged( progress )
end
function HTML:FinishedURL( url )
end
function HTML:OpeningURL( url, target )
end
vgui.Register( "ULXMotd", HTML, "HTML" )
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( "ULX MOTD" )
window:SetVisible( true )
window:MakePopup()
local html = vgui.Create( "ULXMotd", window )
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 )
html:SetHTML( file.Read( "ulx/motd.txt" ) )
end
usermessage.Hook( "SendMotdMenu", ulx.showMotdMenu )
function ulx.rcvMotdStart( um )
ulx.motdContent = ""
end
usermessage.Hook( "ULXMotdStart", ulx.rcvMotdStart )
function ulx.rcvMotdEnd( um )
file.Write( "ulx/motd.txt", ulx.motdContent )
ulx.motdContent = nil
end
usermessage.Hook( "ULXMotdEnd", ulx.rcvMotdEnd )
function ulx.rcvMotdText( um )
ulx.motdContent = ulx.motdContent .. um:ReadString()
end
usermessage.Hook( "ULXMotdText", ulx.rcvMotdText )
addons\ULX\lua\ulx\modules\menus.lua:
if file.Exists( "../lua/ulx/modules/cl/motdmenu.lua" ) then
CreateConVar( "motdfile", "ulx_motd.txt" )
function ulx.cc_motd( ply, command, argv, args )
if not ply:IsValid() then
Msg( "You can't see the motd from the console.\n" )
return
end
if not file.Exists( "../" .. GetConVarString( "motdfile" ) ) then return end -- Invalid
umsg.Start( "SendMotdMenu", ply )
umsg.End()
end
ulx.concommand( "motd", ulx.cc_motd, " - Shows you the message of the day.", ULib.ACCESS_ALL, "!motd", _, ulx.ID_HELP )
local function showMotd( ply )
if not util.tobool( GetConVarString( "ulx_showMotd" ) ) then return end
if not ply:IsValid() then return end -- They left, doh!
if not file.Exists( "../" .. GetConVarString( "motdfile" ) ) then return end -- Invalid
local f = file.Read( "../" .. GetConVarString( "motdfile" ) )
umsg.Start( "ULXMotdStart", ply )
umsg.End()
while f:len() > 0 do
umsg.Start( "ULXMotdText", ply )
umsg.String( f:sub( 1, 240 ) )
umsg.End()
f = f:sub( 241 )
end
umsg.Start( "ULXMotdEnd", ply )
umsg.End()
umsg.Start( "SendMotdMenu", ply )
umsg.End()
end
hook.Add( "ULibPlayerULibLoaded", "showMotd", showMotd )
ulx.convar( "showMotd", "1", " - Shows the motd to clients on startup.", ULib.ACCESS_ADMIN )
end