mirror of
https://github.com/etlegacy/wolfadmin.git
synced 2024-11-21 20:01:18 +00:00
Fixed banners calculation (fixes #98)
* added checks for available banners
This commit is contained in:
parent
311f4877c7
commit
f835d8c6ec
1 changed files with 13 additions and 7 deletions
|
@ -39,16 +39,24 @@ function banners.print(clientId, banner)
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..target.." \"^dbanner: ^9"..banner["text"].."\";")
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..target.." \"^dbanner: ^9"..banner["text"].."\";")
|
||||||
end
|
end
|
||||||
|
|
||||||
function banners.autoprint()
|
function banners.nextBanner(random)
|
||||||
if bits.hasbit(settings.get("g_bannerRandomize"), banners.RANDOM_ALL) then
|
if #infoBanners == 0 then
|
||||||
|
nextBannerId = 0
|
||||||
|
elseif random then
|
||||||
nextBannerId = math.random(#infoBanners)
|
nextBannerId = math.random(#infoBanners)
|
||||||
elseif nextBannerId ~= #infoBanners then
|
elseif nextBannerId ~= #infoBanners then
|
||||||
nextBannerId = nextBannerId + 1
|
nextBannerId = nextBannerId + 1
|
||||||
else
|
else
|
||||||
nextBannerId = 0
|
nextBannerId = 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function banners.autoprint()
|
||||||
|
if nextBannerId ~= 0 and infoBanners[nextBannerId] then
|
||||||
|
banners.print(nil, infoBanners[nextBannerId])
|
||||||
end
|
end
|
||||||
|
|
||||||
banners.print(nil, infoBanners[nextBannerId])
|
banners.nextBanner(bits.hasbit(settings.get("g_bannerRandomize"), banners.RANDOM_ALL))
|
||||||
end
|
end
|
||||||
|
|
||||||
function banners.load()
|
function banners.load()
|
||||||
|
@ -105,9 +113,7 @@ events.handle("onPlayerReady", banners.onPlayerReady)
|
||||||
function banners.onGameInit(levelTime, randomSeed, restartMap)
|
function banners.onGameInit(levelTime, randomSeed, restartMap)
|
||||||
banners.load()
|
banners.load()
|
||||||
|
|
||||||
if bits.hasbit(settings.get("g_bannerRandomize"), banners.RANDOM_START) then
|
banners.nextBanner(bits.hasbit(settings.get("g_bannerRandomize"), banners.RANDOM_START))
|
||||||
nextBannerId = math.random(#infoBanners)
|
|
||||||
end
|
|
||||||
|
|
||||||
bannerTimer = timers.add(banners.autoprint, settings.get("g_bannerInterval") * 1000, 0)
|
bannerTimer = timers.add(banners.autoprint, settings.get("g_bannerInterval") * 1000, 0)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue