forked from TeamUlysses/ulx
Fixed lua errors that pop up when motd generator settings file is invalid.
Fixes #16
This commit is contained in:
parent
7083fc6662
commit
cce7e16414
@ -28,7 +28,7 @@
|
||||
* [FIX] XGUI: Server error in some cases when sorting bans by Unban Date after a new ban has been added.
|
||||
* [FIX] XGUI: Right-clicking an advert group and renaming it was broken.
|
||||
* [CHANGE] MOTD now uses DHTML (Awesomium framework).
|
||||
* [CHANGE] MOTD configuration changes and new "motdurl" CVAR.
|
||||
* [CHANGE] MOTD configuration changes and new "ulx_motdurl" CVAR.
|
||||
* [CHANGE] Data files are now injected from a Lua script rather than included directly, in order to be Workshop-friendly.
|
||||
* [CHANGE] Hook calls to match ULib's new format.
|
||||
* [CHANGE] ULX convar updates will now append an entry to data/config.txt if it is not defined in the file. Previously, these changes would not be saved.
|
||||
|
@ -184,6 +184,18 @@ local template_footer = [[
|
||||
</html>
|
||||
]]
|
||||
|
||||
local template_error = [[
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body style="background-color: white">
|
||||
<div class="footer">
|
||||
<h3>ULX: MOTD Generator error. Could not parse settings file.</h3>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
]]
|
||||
|
||||
local function escape(str)
|
||||
return (str:gsub("<", "<"):gsub(">", ">")) -- Wrapped in parenthesis so we ignore other return vals
|
||||
end
|
||||
@ -213,6 +225,8 @@ local function renderMods()
|
||||
end
|
||||
|
||||
function ulx.generateMotdHTML()
|
||||
if ulx.motdSettings == nil or ulx.motdSettings.info == nil then return template_error end
|
||||
|
||||
local header = string.gsub( template_header, "%%hostname%%", escape(GetHostName() or "") )
|
||||
header = string.gsub( header, "{{(.-)}}", function(a)
|
||||
local success, value = ULib.findVar(a, ulx.motdSettings)
|
||||
|
@ -70,7 +70,7 @@ if ULib.fileExists( "lua/ulx/modules/cl/motdmenu.lua" ) or ulx.motdmenu_exists t
|
||||
ulx.convar( "motdurl", "ulyssesmod.net", "MOTD URL to use if ulx showMotd is 3.", ULib.ACCESS_ADMIN )
|
||||
|
||||
function ulx.populateMotdData()
|
||||
if ulx.motdSettings == nil then return end
|
||||
if ulx.motdSettings == nil or ulx.motdSettings.info == nil then return end
|
||||
|
||||
ulx.motdSettings.admins = {}
|
||||
ulx.motdSettings.addons = nil
|
||||
|
Loading…
Reference in New Issue
Block a user