Compare commits
22 Commits
8a6161a1e1
...
checksum
Author | SHA1 | Date | |
---|---|---|---|
db0696294b | |||
907c07a25d | |||
00aa2060f3 | |||
d7955feaf8 | |||
5a74a428b1 | |||
4f138797a9 | |||
22aa4ecd2f | |||
1305fa2979 | |||
13aeceeedd | |||
7b28cd0777 | |||
ec982d10c3 | |||
f3ec32384a | |||
07dca46c92 | |||
14645dbc90 | |||
6c7cdf34b9 | |||
23a8373230 | |||
14f8769d93 | |||
5080672f7a | |||
5790a3c020 | |||
e3c870eefd | |||
41b152ccf6 | |||
de63c4b2be |
378
leaderboard.lua
378
leaderboard.lua
@ -12,13 +12,30 @@ local splits = {}
|
||||
local PATCH = nil
|
||||
local help = true
|
||||
local EncoreInitial = nil
|
||||
local cv_teamchange
|
||||
local scoreTable
|
||||
|
||||
|
||||
-- Text flash on finish
|
||||
local FlashTics = 0
|
||||
local FlashRate
|
||||
local FlashVFlags
|
||||
local YellowFlash = {
|
||||
[0] = V_YELLOWMAP,
|
||||
[1] = V_ORANGEMAP,
|
||||
[2] = 0
|
||||
}
|
||||
local RedFlash = {
|
||||
[0] = V_REDMAP,
|
||||
[1] = 0
|
||||
}
|
||||
|
||||
-- Tracks if stats have been written or not
|
||||
local StatTrack = false
|
||||
|
||||
local UNCLAIMED = "Unclaimed Record"
|
||||
local HELP_MESSAGE = "\x89Leaderboard Commands:\nretry exit findmap changelevel spba_clearcheats lb_gui rival scroll encore"
|
||||
local FILENAME = "leaderboard.txt"
|
||||
local FILENAME = "leaderboard"
|
||||
|
||||
-- Retry / changelevel map
|
||||
local nextMap = nil
|
||||
@ -81,11 +98,24 @@ local cv_gui = CV_RegisterVar({
|
||||
PossibleValue = {Off = GUI_OFF, Splits = GUI_SPLITS, On = GUI_ON}
|
||||
})
|
||||
|
||||
local cv_afk = CV_RegisterVar({
|
||||
local AntiAFK = true
|
||||
CV_RegisterVar({
|
||||
name = "lb_afk",
|
||||
defaultvalue = 1,
|
||||
flags = CV_NETVAR,
|
||||
PossibleValue = CV_OnOff
|
||||
flags = CV_NETVAR | CV_CALL,
|
||||
PossibleValue = CV_OnOff,
|
||||
func = function(v)
|
||||
-- Set players afkTime and toggle AntiAFK
|
||||
if v.value then
|
||||
for p in players.iterate do
|
||||
p.afkTime = leveltime
|
||||
end
|
||||
|
||||
AntiAFK = true
|
||||
else
|
||||
AntiAFK = false
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
local cv_enable = CV_RegisterVar({
|
||||
@ -120,15 +150,36 @@ local cv_interrupt = CV_RegisterVar({
|
||||
end
|
||||
})
|
||||
|
||||
local function djb2(message)
|
||||
local digest = 5381
|
||||
for c in message:gmatch(".") do
|
||||
digest = (($ << 5) + $) + string.byte(c)
|
||||
end
|
||||
|
||||
return digest
|
||||
end
|
||||
|
||||
local function mapChecksum(mapnum)
|
||||
local mh = mapheaderinfo[mapnum]
|
||||
if not mh then
|
||||
return nil
|
||||
end
|
||||
|
||||
local digest = string.format("%04x", djb2(mh.lvlttl+mh.subttl+mh.zonttl))
|
||||
return string.sub(digest, #digest - 3)
|
||||
end
|
||||
|
||||
local function setST(t, map, flags, scoreTable)
|
||||
local mode = flags & ST_SEP
|
||||
local cks = mapChecksum(map)
|
||||
t[mode] = t[mode] or {}
|
||||
t[mode][map] = scoreTable
|
||||
t[mode][tostring(map)..(cks or "")] = scoreTable
|
||||
end
|
||||
|
||||
local function getST(t, map, flags)
|
||||
local mode = flags & ST_SEP
|
||||
return t[mode] and t[mode][map] or nil
|
||||
local cks = mapChecksum(map)
|
||||
return t[mode] and t[mode][tostring(map)..(cks or "")] or nil
|
||||
end
|
||||
|
||||
local function setScoreTable(map, flags, scoreTable)
|
||||
@ -192,7 +243,7 @@ local cv_spb_separate = CV_RegisterVar({
|
||||
end
|
||||
})
|
||||
|
||||
local function score_t(map, name, skin, color, time, splits, flags, stat)
|
||||
local function score_t(map, name, skin, color, time, splits, flags, stat, checksum)
|
||||
return {
|
||||
["map"] = map,
|
||||
["name"] = name,
|
||||
@ -201,7 +252,8 @@ local function score_t(map, name, skin, color, time, splits, flags, stat)
|
||||
["time"] = time,
|
||||
["splits"] = splits,
|
||||
["flags"] = flags,
|
||||
["stat"] = stat
|
||||
["stat"] = stat,
|
||||
["checksum"] = checksum
|
||||
}
|
||||
end
|
||||
|
||||
@ -223,12 +275,47 @@ local function stat_str(stat)
|
||||
return "0"
|
||||
end
|
||||
|
||||
local function writeScore(fh, score)
|
||||
fh:write(
|
||||
score["map"], "\t",
|
||||
score["name"], "\t",
|
||||
score["skin"], "\t",
|
||||
score["color"], "\t",
|
||||
score["time"], "\t",
|
||||
table.concat(score["splits"], " "), "\t",
|
||||
score["flags"], "\t",
|
||||
stat_str(score["stat"]), "\t",
|
||||
score["checksum"], "\n"
|
||||
)
|
||||
end
|
||||
|
||||
local function saveScores()
|
||||
local f = assert(io.open(FILENAME + ".txt", "w"))
|
||||
if f == nil then
|
||||
print("Failed to open file for writing: " + FILENAME + ".txt")
|
||||
return
|
||||
end
|
||||
|
||||
for _, tbl in pairs(lb) do
|
||||
for _, scoreTable in pairs(tbl) do
|
||||
for _, score in ipairs(scoreTable) do
|
||||
writeScore(f, score)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
f:close()
|
||||
end
|
||||
|
||||
-- Read the leaderboard
|
||||
local f = io.open(FILENAME, "r")
|
||||
local f = io.open(FILENAME + ".txt", "r")
|
||||
if f then
|
||||
-- track if scores checksums have been written
|
||||
local checksumWrite = false
|
||||
|
||||
for l in f:lines() do
|
||||
-- Leaderboard is stored in the following tab separated format
|
||||
-- mapnum, name, skin, color, time, splits, flags, stat
|
||||
-- mapnum, name, skin, color, time, splits, flags, stat, map_checksum
|
||||
local t = {}
|
||||
for word in (l+"\t"):gmatch("(.-)\t") do
|
||||
table.insert(t, word)
|
||||
@ -239,7 +326,7 @@ if f then
|
||||
flags = tonumber(t[7])
|
||||
end
|
||||
|
||||
local scoreTable = getScoreTable(tonumber(t[1]), flags) or {}
|
||||
scoreTable = getScoreTable(tonumber(t[1]), flags) or {}
|
||||
|
||||
local spl = {}
|
||||
if t[6] != nil then
|
||||
@ -257,17 +344,41 @@ if f then
|
||||
end
|
||||
end
|
||||
|
||||
local mapnum = tonumber(t[1])
|
||||
|
||||
-- Checksums
|
||||
local cks = t[9]
|
||||
|
||||
if cks == nil then
|
||||
checksumWrite = true
|
||||
cks = mapChecksum(mapnum)
|
||||
|
||||
-- We have no previous recognition of this map
|
||||
-- remove it
|
||||
if cks == nil then
|
||||
local rsfh = io.open(FILENAME + "_removed_scores.txt", "a")
|
||||
if not rsfh then
|
||||
print("Failed to open file: ", FILENAME + "_removed_scores.txt")
|
||||
continue
|
||||
end
|
||||
rsfh:write(l, "\n")
|
||||
rsfh:close()
|
||||
continue
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(
|
||||
scoreTable,
|
||||
score_t(
|
||||
tonumber(t[1]),
|
||||
mapnum,
|
||||
t[2],
|
||||
t[3],
|
||||
t[4],
|
||||
tonumber(t[5]),
|
||||
spl,
|
||||
flags,
|
||||
stats
|
||||
stats,
|
||||
cks
|
||||
)
|
||||
)
|
||||
|
||||
@ -276,8 +387,13 @@ if f then
|
||||
|
||||
sortScores()
|
||||
f:close()
|
||||
|
||||
-- save scores
|
||||
if checksumWrite then
|
||||
saveScores()
|
||||
end
|
||||
else
|
||||
print("Failed to open file: ", FILENAME)
|
||||
print("Failed to open file: ", FILENAME + ".txt")
|
||||
end
|
||||
|
||||
function allowJoin(v)
|
||||
@ -295,23 +411,27 @@ function allowJoin(v)
|
||||
end
|
||||
end
|
||||
|
||||
local function ingame()
|
||||
-- Returns true if there is a single player ingame
|
||||
local function singleplayer()
|
||||
local n = 0
|
||||
for p in players.iterate do
|
||||
if p.valid and not p.spectator then
|
||||
n = $ + 1
|
||||
if n > 1 then
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
return n
|
||||
return true
|
||||
end
|
||||
|
||||
local function initLeaderboard(player)
|
||||
if disable and leveltime < START_TIME then
|
||||
disable = ingame() > 1
|
||||
disable = not singleplayer()
|
||||
else
|
||||
disable = disable or ingame() > 1
|
||||
disable = disable or not singleplayer()
|
||||
end
|
||||
disable = $ or not cv_enable.value
|
||||
disable = $ or not cv_enable.value or not (maptol & (TOL_SP | TOL_RACE))
|
||||
|
||||
-- Restore encore mode to initial value
|
||||
if disable and EncoreInitial != nil then
|
||||
@ -324,7 +444,7 @@ end
|
||||
addHook("PlayerSpawn", initLeaderboard)
|
||||
|
||||
local function doyoudare(player)
|
||||
if ingame() > 1 or player.spectator then
|
||||
if not singleplayer() or player.spectator then
|
||||
CONS_Printf(player, "How dare you")
|
||||
return false
|
||||
end
|
||||
@ -351,24 +471,57 @@ COM_AddCommand("exit", exitlevel)
|
||||
|
||||
local function findMap(player, ...)
|
||||
local search = ...
|
||||
if search == nil then
|
||||
|
||||
return
|
||||
local hell = "\x85HELL"
|
||||
local tol = {
|
||||
[TOL_SP] = "\x81Race\x80", -- Nuked race maps
|
||||
[TOL_COOP] = "\x8D\Battle\x80", -- Nuked battle maps
|
||||
[TOL_RACE] = "\x88Race\x80",
|
||||
[TOL_MATCH] = "\x87\Battle\x80"
|
||||
}
|
||||
local lvltype, map, lvlttl
|
||||
|
||||
local zoneAct = function(zone, act, levelflags)
|
||||
local z = ""
|
||||
if zone != "" then
|
||||
z = " " + zone
|
||||
elseif not(levelflags & LF_NOZONE) then
|
||||
z = " Zone"
|
||||
end
|
||||
if act != "" then
|
||||
z = $ + " " + act
|
||||
end
|
||||
|
||||
return z
|
||||
end
|
||||
|
||||
|
||||
for i = 1, #mapheaderinfo do
|
||||
local map = mapheaderinfo[i]
|
||||
map = mapheaderinfo[i]
|
||||
if map == nil then
|
||||
continue
|
||||
end
|
||||
|
||||
if map.lvlttl:lower():find(search:lower()) then
|
||||
lvlttl = map.lvlttl + zoneAct(map.zonttl, map.actnum, map.levelflags)
|
||||
|
||||
if not search or lvlttl:lower():find(search:lower()) then
|
||||
-- Only care for up to TOL_MATCH (0x10)
|
||||
lvltype = tol[map.typeoflevel & 0x1F] or map.typeoflevel
|
||||
|
||||
-- If not battle print numlaps
|
||||
lvltype = (map.typeoflevel & (TOL_MATCH | TOL_COOP) and lvltype)
|
||||
or string.format("%s \x82%-2d\x80", lvltype, map.numlaps)
|
||||
|
||||
|
||||
CONS_Printf(
|
||||
player,
|
||||
string.format(
|
||||
"%s - %s",
|
||||
"%s %-9s %-30s - %s\t%s",
|
||||
G_BuildMapName(i),
|
||||
map.lvlttl
|
||||
lvltype,
|
||||
lvlttl,
|
||||
map.subttl,
|
||||
(map.menuflags & LF2_HIDEINMENU and hell) or ""
|
||||
)
|
||||
)
|
||||
end
|
||||
@ -380,8 +533,6 @@ local function mapNotExists(player, map)
|
||||
CONS_Printf(player, string.format("Map doesn't exist: %s", map:upper()))
|
||||
end
|
||||
|
||||
local ALPH = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
|
||||
local function changelevel(player, ...)
|
||||
if not doyoudare(player) then
|
||||
return
|
||||
@ -403,6 +554,8 @@ local function changelevel(player, ...)
|
||||
end
|
||||
|
||||
local mapnum = 0
|
||||
local A = string.byte("A")
|
||||
|
||||
if tonumber(p) != nil then
|
||||
-- Non extended map numbers
|
||||
if tonumber(q) == nil then
|
||||
@ -412,11 +565,12 @@ local function changelevel(player, ...)
|
||||
mapnum = tonumber(p) * 10 + tonumber(q)
|
||||
else
|
||||
--Extended map numbers
|
||||
p = ALPH:find(p) - 1
|
||||
p = string.byte(p) - A
|
||||
local qn = tonumber(q)
|
||||
if qn == nil then
|
||||
qn = ALPH:find(q) + 9
|
||||
qn = string.byte(q) - A + 10
|
||||
end
|
||||
|
||||
mapnum = 36 * p + qn + 100
|
||||
end
|
||||
|
||||
@ -425,6 +579,12 @@ local function changelevel(player, ...)
|
||||
return
|
||||
end
|
||||
|
||||
-- Verify valid race level
|
||||
if not (mapheaderinfo[mapnum].typeoflevel & (TOL_SP | TOL_RACE)) then
|
||||
CONS_Printf(player, "Battle maps are not supported")
|
||||
return
|
||||
end
|
||||
|
||||
nextMap = G_BuildMapName(mapnum)
|
||||
end
|
||||
COM_AddCommand("changelevel", changelevel)
|
||||
@ -647,6 +807,7 @@ addHook("MapLoad", function()
|
||||
drawState = DS_DEFAULT
|
||||
scrollY = 50 * FRACUNIT
|
||||
scrollAcc = 0
|
||||
FlashTics = 0
|
||||
|
||||
allowJoin(true)
|
||||
--printTable(lb)
|
||||
@ -660,7 +821,7 @@ function ticsToTime(tics, pure)
|
||||
|
||||
return string.format(
|
||||
"%d:%02d:%02d",
|
||||
G_TicsToMinutes(tics),
|
||||
G_TicsToMinutes(tics, true),
|
||||
G_TicsToSeconds(tics),
|
||||
G_TicsToCentiseconds(tics)
|
||||
)
|
||||
@ -739,10 +900,11 @@ local FACERANK_DIM = 16
|
||||
local FACERANK_SPC = FACERANK_DIM + 4
|
||||
local function drawScore(v, player, pos, x, y, gui, faceRank, score, drawPos, textVFlags)
|
||||
textVFlags = textVFlags or V_HUDTRANSHALF
|
||||
local me = player.name == score["name"]
|
||||
|
||||
--draw Patch/chili
|
||||
v.draw(x, y, faceRank, V_HUDTRANS | VFLAGS, v.getColormap("sonic", score["color"]))
|
||||
if player.name == score["name"] then
|
||||
if me then
|
||||
v.draw(x, y, PATCH["CHILI"][(leveltime / 4) % 8], V_HUDTRANS | VFLAGS)
|
||||
end
|
||||
|
||||
@ -754,7 +916,7 @@ local function drawScore(v, player, pos, x, y, gui, faceRank, score, drawPos, te
|
||||
bob + (y + FACERANK_DIM / 2) * FRACUNIT,
|
||||
FRACUNIT / 6,
|
||||
PATCH["RUBY"],
|
||||
V_HUDTRANS
|
||||
V_HUDTRANS | VFLAGS
|
||||
)
|
||||
end
|
||||
|
||||
@ -838,11 +1000,16 @@ local function drawScore(v, player, pos, x, y, gui, faceRank, score, drawPos, te
|
||||
end
|
||||
end
|
||||
|
||||
local flashV = 0
|
||||
if me and FlashTics > leveltime then
|
||||
flashV = FlashVFlags[leveltime / FlashRate % (#FlashVFlags + 1)]
|
||||
end
|
||||
|
||||
v.drawString(
|
||||
x + FACERANK_DIM + px,
|
||||
y + py,
|
||||
name,
|
||||
textVFlags | V_ALLOWLOWERCASE | VFLAGS,
|
||||
textVFlags | V_ALLOWLOWERCASE | VFLAGS | flashV,
|
||||
stralign
|
||||
)
|
||||
|
||||
@ -860,7 +1027,7 @@ local function drawScore(v, player, pos, x, y, gui, faceRank, score, drawPos, te
|
||||
x + px + FACERANK_DIM,
|
||||
y + 8,
|
||||
ticsToTime(score["time"], true),
|
||||
textVFlags | bodium[min(pos, 4)] | VFLAGS
|
||||
textVFlags | bodium[min(pos, 4)] | VFLAGS | flashV
|
||||
)
|
||||
end
|
||||
end
|
||||
@ -907,9 +1074,9 @@ local function drawScroll(v, player, scoreTable, gui)
|
||||
local x = 10
|
||||
if #scoreTable >= 10 then
|
||||
x = x + 8
|
||||
end
|
||||
if #scoreTable >= 100 then
|
||||
x = x + 8
|
||||
if #scoreTable >= 100 then
|
||||
x = x + 8
|
||||
end
|
||||
end
|
||||
|
||||
local y = FixedInt(scrollY)
|
||||
@ -961,8 +1128,6 @@ local function drawScoreboard(v, player)
|
||||
|
||||
cachePatches(v)
|
||||
|
||||
local scoreTable = getScoreTable(gamemap, Flags)
|
||||
|
||||
local gui = cv_gui.value
|
||||
if leveltime < START_TIME or player.exiting or player.lives == 0 then
|
||||
gui = GUI_ON
|
||||
@ -1009,7 +1174,7 @@ end
|
||||
|
||||
-- Find location of player and scroll to it
|
||||
function scroll_to(player)
|
||||
local m = getScoreTable(gamemap, Flags) or {}
|
||||
local m = scoreTable or {}
|
||||
|
||||
scrollToPos = 2
|
||||
for pos, score in ipairs(m) do
|
||||
@ -1038,7 +1203,8 @@ local function writeStats()
|
||||
end
|
||||
|
||||
local function saveTime(player)
|
||||
local scoreTable = getScoreTable(gamemap, Flags) or {}
|
||||
|
||||
scoreTable = $ or {}
|
||||
|
||||
local pskin = skins[player.mo.skin]
|
||||
local newscore = score_t(
|
||||
@ -1049,7 +1215,8 @@ local function saveTime(player)
|
||||
timeFinished,
|
||||
splits,
|
||||
Flags,
|
||||
stat_t(player.HMRs or pskin.kartspeed, player.HMRw or pskin.kartweight)
|
||||
stat_t(player.HMRs or pskin.kartspeed, player.HMRw or pskin.kartweight),
|
||||
mapChecksum(gamemap)
|
||||
)
|
||||
|
||||
-- Check if you beat your previous best
|
||||
@ -1058,10 +1225,16 @@ local function saveTime(player)
|
||||
if lbComp(newscore, scoreTable[i]) then
|
||||
table.remove(scoreTable, i)
|
||||
S_StartSound(nil, 130)
|
||||
FlashTics = leveltime + TICRATE * 3
|
||||
FlashRate = 1
|
||||
FlashVFlags = YellowFlash
|
||||
break
|
||||
else
|
||||
-- You suck lol
|
||||
S_StartSound(nil, 201)
|
||||
FlashTics = leveltime + TICRATE * 3
|
||||
FlashRate = 3
|
||||
FlashVFlags = RedFlash
|
||||
scroll_to(player)
|
||||
return
|
||||
end
|
||||
@ -1088,30 +1261,7 @@ local function saveTime(player)
|
||||
StatTrack = true
|
||||
end
|
||||
|
||||
local f = assert(io.open(FILENAME, "w"))
|
||||
if f == nil then
|
||||
print("Failed to open file for writing: " + FILENAME)
|
||||
return
|
||||
end
|
||||
|
||||
for _, tbl in pairs(lb) do
|
||||
for _, scoreTable in pairs(tbl) do
|
||||
for _, score in ipairs(scoreTable) do
|
||||
f:write(
|
||||
score["map"], "\t",
|
||||
score["name"], "\t",
|
||||
score["skin"], "\t",
|
||||
score["color"], "\t",
|
||||
score["time"], "\t",
|
||||
table.concat(score["splits"], " "), "\t",
|
||||
score["flags"], "\t",
|
||||
stat_str(score["stat"]), "\n"
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
f:close()
|
||||
saveScores()
|
||||
end
|
||||
|
||||
-- DEBUGGING
|
||||
@ -1138,35 +1288,39 @@ local function getGamer()
|
||||
end
|
||||
end
|
||||
|
||||
local function changeMap()
|
||||
COM_BufInsertText(server, "map " + nextMap + " -force -gametype race")
|
||||
nextMap = nil
|
||||
end
|
||||
|
||||
local function think()
|
||||
if nextMap then
|
||||
COM_BufInsertText(server, "map " + nextMap)
|
||||
nextMap = nil
|
||||
end
|
||||
if nextMap then changeMap() end
|
||||
|
||||
if disable then
|
||||
if cv_afk.value and ingame() > 1 then
|
||||
for p in players.iterate do
|
||||
if p.valid and not p.spectator and not p.exiting and p.lives > 0 then
|
||||
if p.cmd.buttons then
|
||||
p.afkTime = leveltime
|
||||
end
|
||||
if AntiAFK then
|
||||
if not singleplayer() then
|
||||
for p in players.iterate do
|
||||
if p.valid and not p.spectator and not p.exiting and p.lives > 0 then
|
||||
if p.cmd.buttons then
|
||||
p.afkTime = leveltime
|
||||
end
|
||||
|
||||
--Away from kart
|
||||
if p.afkTime + AFK_BALANCE_WARN == leveltime then
|
||||
chatprintf(p, "[AFK] \x89You will be moved to spectator in 10 seconds!", false)
|
||||
S_StartSound(nil, 26, p)
|
||||
end
|
||||
if p.afkTime + AFK_BALANCE < leveltime then
|
||||
p.spectator = true
|
||||
chatprint("\x89" + p.name + " was moved to the other team for game balance", true)
|
||||
--Away from kart
|
||||
if p.afkTime + AFK_BALANCE_WARN == leveltime then
|
||||
chatprintf(p, "[AFK] \x89You will be moved to spectator in 10 seconds!", false)
|
||||
S_StartSound(nil, 26, p)
|
||||
end
|
||||
if p.afkTime + AFK_BALANCE < leveltime then
|
||||
p.spectator = true
|
||||
chatprint("\x89" + p.name + " was moved to the other team for game balance", true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
for p in players.iterate do
|
||||
if p.valid and not p.spectator then
|
||||
p.afkTime = leveltime
|
||||
else
|
||||
for p in players.iterate do
|
||||
if p.valid and not p.spectator then
|
||||
p.afkTime = leveltime
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1181,7 +1335,7 @@ local function think()
|
||||
if leveltime < START_TIME then
|
||||
-- Help message
|
||||
if leveltime == START_TIME - TICRATE * 3 then
|
||||
if ingame() == 1 then
|
||||
if singleplayer() then
|
||||
if help then
|
||||
help = false
|
||||
chatprint(HELP_MESSAGE, true)
|
||||
@ -1217,29 +1371,34 @@ local function think()
|
||||
end
|
||||
if clearcheats then
|
||||
clearcheats = false
|
||||
for p in players.iterate do
|
||||
p.SPBAKARTBIG = false
|
||||
p.SPBAjustice = false
|
||||
p.SPBAshutup = false
|
||||
for q in players.iterate do
|
||||
q.SPBAKARTBIG = false
|
||||
q.SPBAjustice = false
|
||||
q.SPBAshutup = false
|
||||
end
|
||||
end
|
||||
for p in players.iterate do
|
||||
if not p.spectator then
|
||||
if p.SPBAKARTBIG then
|
||||
Flags = $ | F_SPBBIG
|
||||
end
|
||||
if p.SPBAjustice then
|
||||
Flags = $ | F_SPBJUS
|
||||
end
|
||||
|
||||
if p then
|
||||
if p.SPBAKARTBIG then
|
||||
Flags = $ | F_SPBBIG
|
||||
end
|
||||
if p.SPBAjustice then
|
||||
Flags = $ | F_SPBJUS
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
if not (Flags & F_SPBATK) then
|
||||
hud.enable("freeplay")
|
||||
end
|
||||
end
|
||||
|
||||
local cv_teamchange = CV_FindVar("allowteamchange")
|
||||
scoreTable = getScoreTable(gamemap, Flags)
|
||||
|
||||
if not cv_teamchange then
|
||||
cv_teamchange = CV_FindVar("allowteamchange")
|
||||
end
|
||||
|
||||
if p then
|
||||
-- Scroll controller
|
||||
-- Spectators can't input buttons so let the gamer do it
|
||||
@ -1288,15 +1447,18 @@ end
|
||||
addHook("ThinkFrame", think)
|
||||
|
||||
local function interThink()
|
||||
if nextMap then
|
||||
COM_BufInsertText(server, "map " + nextMap)
|
||||
nextMap = nil
|
||||
if nextMap then changeMap() end
|
||||
|
||||
if not cv_teamchange then
|
||||
cv_teamchange = CV_FindVar("allowteamchange")
|
||||
end
|
||||
if not CV_FindVar("allowteamchange").value then
|
||||
|
||||
if not cv_teamchange.value then
|
||||
allowJoin(true)
|
||||
end
|
||||
end
|
||||
addHook("IntermissionThinker", interThink)
|
||||
addHook("VoteThinker", interThink)
|
||||
|
||||
-- Returns the values clamed between min, max
|
||||
function clamp(min_v, v, max_v)
|
||||
|
Reference in New Issue
Block a user