Extended banner to support area prints

This commit is contained in:
isRyven 2020-03-10 14:34:26 +02:00 committed by Timo Smit
parent 3027d49847
commit 95da07cdae
5 changed files with 54 additions and 5 deletions

View File

@ -19,6 +19,8 @@ local bits = wolfa_requireModule("util.bits")
local events = wolfa_requireModule("util.events")
local settings = wolfa_requireModule("util.settings")
local timers = wolfa_requireModule("util.timers")
local constants = wolfa_requireModule("util.constants")
local util = wolfa_requireModule("util.util")
local toml = wolfa_requireLib("toml")
@ -34,9 +36,10 @@ local welcomeBanners = {}
local infoBanners = {}
function banners.print(clientId, banner)
local prefix = (settings.get("g_bannerArea") ~= constants.AREA_CHAT) and "^7" or "^dbanner: ^9"
local target = clientId and clientId or -1
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..target.." \"^dbanner: ^9"..banner["text"].."\";")
et.trap_SendConsoleCommand(et.EXEC_APPEND,
string.format("%s %i \"%s%s\";", util.getCommandForArea(settings.get("g_bannerArea")), target, prefix, banner["text"]))
end
function banners.nextBanner(random)
@ -114,8 +117,8 @@ function banners.onGameInit(levelTime, randomSeed, restartMap)
banners.load()
banners.nextBanner(bits.hasbit(settings.get("g_bannerRandomize"), banners.RANDOM_START))
bannerTimer = timers.add(banners.autoprint, settings.get("g_bannerInterval") * 1000, 0)
end
events.handle("onGameInit", banners.onGameInit)

View File

@ -0,0 +1,27 @@
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
-- Copyright (C) 2015-2019 Timo 'Timothy' Smit
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- at your option any later version.
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local commands = wolfa_requireModule("commands.commands")
local util = wolfa_requireModule("util.util")
function commandBannerPrint(command, clientId, text)
et.trap_SendServerCommand(clientId, "bp \""..text.."\";")
return true
end
commands.addserver("cbp", commandBannerPrint)

View File

@ -68,6 +68,7 @@ constants.AREA_CONSOLE = 0
constants.AREA_POPUPS = 1
constants.AREA_CHAT = 2
constants.AREA_CP = 3
constants.AREA_BP = 4
constants.VOTE_TYPES = { "antilag", "balancedteams", "comp", "friendlyfire", "gamconstantsype", "kick",
"map", "maprestart", "matchresconstants", "mutespecs", "muting", "nextcampaign", "nextmap",

View File

@ -37,7 +37,7 @@ local data = {
["g_botGreetings"] = 1,
["g_bannerInterval"] = 120,
["g_bannerRandomize"] = 1,
["g_welcomeArea"] = 3,
["g_bannerArea"] = 4,
["g_evenerMinDifference"] = 2,
["g_evenerMaxDifference"] = 5,
["g_evenerPlayerSelection"] = 0,
@ -100,7 +100,7 @@ local cfgStructure = {
["file"] = "g_fileBanners",
["interval"] = "g_bannerInterval",
["random"] = "g_bannerRandomize",
["area"] = "g_welcomeArea"
["area"] = "g_bannerArea"
},
["rules"] = {
["file"] = "g_fileRules"

View File

@ -133,11 +133,29 @@ function util.getAreaName(areaId)
return "cchat -1"
elseif areaId == constants.AREA_CP then
return "cp"
elseif areaId == constants.AREA_BP then
return "bp"
else
return "cp"
end
end
function util.getCommandForArea(areaId)
if areaId == constants.AREA_CONSOLE then
return "csay"
elseif areaId == constants.AREA_POPUPS then
return "ccpm"
elseif areaId == constants.AREA_CHAT then
return "cchat"
elseif areaId == constants.AREA_CP then
return "ccp"
elseif areaId == constants.AREA_BP then
return "cbp"
else
return "ccp"
end
end
function util.getTimeFromString(str)
if tonumber(str) then return tonumber(str) end