mirror of
https://github.com/etlegacy/wolfadmin.git
synced 2024-11-21 20:01:18 +00:00
Extended banner to support area prints
This commit is contained in:
parent
3027d49847
commit
95da07cdae
5 changed files with 54 additions and 5 deletions
|
@ -19,6 +19,8 @@ local bits = wolfa_requireModule("util.bits")
|
||||||
local events = wolfa_requireModule("util.events")
|
local events = wolfa_requireModule("util.events")
|
||||||
local settings = wolfa_requireModule("util.settings")
|
local settings = wolfa_requireModule("util.settings")
|
||||||
local timers = wolfa_requireModule("util.timers")
|
local timers = wolfa_requireModule("util.timers")
|
||||||
|
local constants = wolfa_requireModule("util.constants")
|
||||||
|
local util = wolfa_requireModule("util.util")
|
||||||
|
|
||||||
local toml = wolfa_requireLib("toml")
|
local toml = wolfa_requireLib("toml")
|
||||||
|
|
||||||
|
@ -34,9 +36,10 @@ local welcomeBanners = {}
|
||||||
local infoBanners = {}
|
local infoBanners = {}
|
||||||
|
|
||||||
function banners.print(clientId, banner)
|
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
|
local target = clientId and clientId or -1
|
||||||
|
et.trap_SendConsoleCommand(et.EXEC_APPEND,
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..target.." \"^dbanner: ^9"..banner["text"].."\";")
|
string.format("%s %i \"%s%s\";", util.getCommandForArea(settings.get("g_bannerArea")), target, prefix, banner["text"]))
|
||||||
end
|
end
|
||||||
|
|
||||||
function banners.nextBanner(random)
|
function banners.nextBanner(random)
|
||||||
|
@ -114,8 +117,8 @@ function banners.onGameInit(levelTime, randomSeed, restartMap)
|
||||||
banners.load()
|
banners.load()
|
||||||
|
|
||||||
banners.nextBanner(bits.hasbit(settings.get("g_bannerRandomize"), banners.RANDOM_START))
|
banners.nextBanner(bits.hasbit(settings.get("g_bannerRandomize"), banners.RANDOM_START))
|
||||||
|
|
||||||
bannerTimer = timers.add(banners.autoprint, settings.get("g_bannerInterval") * 1000, 0)
|
bannerTimer = timers.add(banners.autoprint, settings.get("g_bannerInterval") * 1000, 0)
|
||||||
|
|
||||||
end
|
end
|
||||||
events.handle("onGameInit", banners.onGameInit)
|
events.handle("onGameInit", banners.onGameInit)
|
||||||
|
|
||||||
|
|
27
luascripts/wolfadmin/commands/server/cbp.lua
Normal file
27
luascripts/wolfadmin/commands/server/cbp.lua
Normal 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)
|
|
@ -68,6 +68,7 @@ constants.AREA_CONSOLE = 0
|
||||||
constants.AREA_POPUPS = 1
|
constants.AREA_POPUPS = 1
|
||||||
constants.AREA_CHAT = 2
|
constants.AREA_CHAT = 2
|
||||||
constants.AREA_CP = 3
|
constants.AREA_CP = 3
|
||||||
|
constants.AREA_BP = 4
|
||||||
|
|
||||||
constants.VOTE_TYPES = { "antilag", "balancedteams", "comp", "friendlyfire", "gamconstantsype", "kick",
|
constants.VOTE_TYPES = { "antilag", "balancedteams", "comp", "friendlyfire", "gamconstantsype", "kick",
|
||||||
"map", "maprestart", "matchresconstants", "mutespecs", "muting", "nextcampaign", "nextmap",
|
"map", "maprestart", "matchresconstants", "mutespecs", "muting", "nextcampaign", "nextmap",
|
||||||
|
|
|
@ -37,7 +37,7 @@ local data = {
|
||||||
["g_botGreetings"] = 1,
|
["g_botGreetings"] = 1,
|
||||||
["g_bannerInterval"] = 120,
|
["g_bannerInterval"] = 120,
|
||||||
["g_bannerRandomize"] = 1,
|
["g_bannerRandomize"] = 1,
|
||||||
["g_welcomeArea"] = 3,
|
["g_bannerArea"] = 4,
|
||||||
["g_evenerMinDifference"] = 2,
|
["g_evenerMinDifference"] = 2,
|
||||||
["g_evenerMaxDifference"] = 5,
|
["g_evenerMaxDifference"] = 5,
|
||||||
["g_evenerPlayerSelection"] = 0,
|
["g_evenerPlayerSelection"] = 0,
|
||||||
|
@ -100,7 +100,7 @@ local cfgStructure = {
|
||||||
["file"] = "g_fileBanners",
|
["file"] = "g_fileBanners",
|
||||||
["interval"] = "g_bannerInterval",
|
["interval"] = "g_bannerInterval",
|
||||||
["random"] = "g_bannerRandomize",
|
["random"] = "g_bannerRandomize",
|
||||||
["area"] = "g_welcomeArea"
|
["area"] = "g_bannerArea"
|
||||||
},
|
},
|
||||||
["rules"] = {
|
["rules"] = {
|
||||||
["file"] = "g_fileRules"
|
["file"] = "g_fileRules"
|
||||||
|
|
|
@ -133,11 +133,29 @@ function util.getAreaName(areaId)
|
||||||
return "cchat -1"
|
return "cchat -1"
|
||||||
elseif areaId == constants.AREA_CP then
|
elseif areaId == constants.AREA_CP then
|
||||||
return "cp"
|
return "cp"
|
||||||
|
elseif areaId == constants.AREA_BP then
|
||||||
|
return "bp"
|
||||||
else
|
else
|
||||||
return "cp"
|
return "cp"
|
||||||
end
|
end
|
||||||
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)
|
function util.getTimeFromString(str)
|
||||||
if tonumber(str) then return tonumber(str) end
|
if tonumber(str) then return tonumber(str) end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue