forked from Not/srb2k-leaderboard
Compare commits
No commits in common. "14645dbc90af6c02074c64a5e23ec7c4649cfa5f" and "5cecda05f1d52080404bdfab7b8f6a6d660fe94f" have entirely different histories.
14645dbc90
...
5cecda05f1
135
leaderboard.lua
135
leaderboard.lua
@ -12,8 +12,6 @@ local splits = {}
|
||||
local PATCH = nil
|
||||
local help = true
|
||||
local EncoreInitial = nil
|
||||
local cv_teamchange
|
||||
local scoreTable
|
||||
|
||||
-- Tracks if stats have been written or not
|
||||
local StatTrack = false
|
||||
@ -83,24 +81,11 @@ local cv_gui = CV_RegisterVar({
|
||||
PossibleValue = {Off = GUI_OFF, Splits = GUI_SPLITS, On = GUI_ON}
|
||||
})
|
||||
|
||||
local AntiAFK = true
|
||||
CV_RegisterVar({
|
||||
local cv_afk = CV_RegisterVar({
|
||||
name = "lb_afk",
|
||||
defaultvalue = 1,
|
||||
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
|
||||
flags = CV_NETVAR,
|
||||
PossibleValue = CV_OnOff
|
||||
})
|
||||
|
||||
local cv_enable = CV_RegisterVar({
|
||||
@ -254,7 +239,7 @@ if f then
|
||||
flags = tonumber(t[7])
|
||||
end
|
||||
|
||||
scoreTable = getScoreTable(tonumber(t[1]), flags) or {}
|
||||
local scoreTable = getScoreTable(tonumber(t[1]), flags) or {}
|
||||
|
||||
local spl = {}
|
||||
if t[6] != nil then
|
||||
@ -675,7 +660,7 @@ function ticsToTime(tics, pure)
|
||||
|
||||
return string.format(
|
||||
"%d:%02d:%02d",
|
||||
G_TicsToMinutes(tics, true),
|
||||
G_TicsToMinutes(tics),
|
||||
G_TicsToSeconds(tics),
|
||||
G_TicsToCentiseconds(tics)
|
||||
)
|
||||
@ -922,9 +907,9 @@ local function drawScroll(v, player, scoreTable, gui)
|
||||
local x = 10
|
||||
if #scoreTable >= 10 then
|
||||
x = x + 8
|
||||
if #scoreTable >= 100 then
|
||||
x = x + 8
|
||||
end
|
||||
end
|
||||
if #scoreTable >= 100 then
|
||||
x = x + 8
|
||||
end
|
||||
|
||||
local y = FixedInt(scrollY)
|
||||
@ -975,6 +960,8 @@ local function drawScoreboard(v, player)
|
||||
if player != displayplayers[0] then return end
|
||||
|
||||
cachePatches(v)
|
||||
|
||||
local scoreTable = getScoreTable(gamemap, Flags)
|
||||
|
||||
local gui = cv_gui.value
|
||||
if leveltime < START_TIME or player.exiting or player.lives == 0 then
|
||||
@ -1022,7 +1009,7 @@ end
|
||||
|
||||
-- Find location of player and scroll to it
|
||||
function scroll_to(player)
|
||||
local m = scoreTable or {}
|
||||
local m = getScoreTable(gamemap, Flags) or {}
|
||||
|
||||
scrollToPos = 2
|
||||
for pos, score in ipairs(m) do
|
||||
@ -1051,8 +1038,7 @@ local function writeStats()
|
||||
end
|
||||
|
||||
local function saveTime(player)
|
||||
|
||||
scoreTable = $ or {}
|
||||
local scoreTable = getScoreTable(gamemap, Flags) or {}
|
||||
|
||||
local pskin = skins[player.mo.skin]
|
||||
local newscore = score_t(
|
||||
@ -1159,30 +1145,28 @@ local function think()
|
||||
end
|
||||
|
||||
if disable then
|
||||
if AntiAFK then
|
||||
if 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
|
||||
|
||||
--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
|
||||
else
|
||||
for p in players.iterate do
|
||||
if p.valid and not p.spectator 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
|
||||
|
||||
--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
|
||||
else
|
||||
for p in players.iterate do
|
||||
if p.valid and not p.spectator then
|
||||
p.afkTime = leveltime
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1233,34 +1217,29 @@ local function think()
|
||||
end
|
||||
if clearcheats then
|
||||
clearcheats = false
|
||||
for q in players.iterate do
|
||||
q.SPBAKARTBIG = false
|
||||
q.SPBAjustice = false
|
||||
q.SPBAshutup = false
|
||||
for p in players.iterate do
|
||||
p.SPBAKARTBIG = false
|
||||
p.SPBAjustice = false
|
||||
p.SPBAshutup = false
|
||||
end
|
||||
end
|
||||
|
||||
if p then
|
||||
if p.SPBAKARTBIG then
|
||||
Flags = $ | F_SPBBIG
|
||||
end
|
||||
if p.SPBAjustice then
|
||||
Flags = $ | F_SPBJUS
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
if not (Flags & F_SPBATK) then
|
||||
hud.enable("freeplay")
|
||||
end
|
||||
end
|
||||
|
||||
scoreTable = getScoreTable(gamemap, Flags)
|
||||
|
||||
if not cv_teamchange then
|
||||
cv_teamchange = CV_FindVar("allowteamchange")
|
||||
end
|
||||
|
||||
local cv_teamchange = CV_FindVar("allowteamchange")
|
||||
if p then
|
||||
-- Scroll controller
|
||||
-- Spectators can't input buttons so let the gamer do it
|
||||
@ -1285,15 +1264,13 @@ local function think()
|
||||
p.afkTime = leveltime
|
||||
end
|
||||
|
||||
if not replayplayback then
|
||||
if leveltime > PREVENT_JOIN_TIME and p.afkTime + AFK_TIMEOUT > leveltime then
|
||||
if cv_teamchange.value then
|
||||
allowJoin(false)
|
||||
end
|
||||
elseif p.afkTime + AFK_TIMEOUT < leveltime then
|
||||
if not cv_teamchange.value then
|
||||
allowJoin(true)
|
||||
end
|
||||
if leveltime > PREVENT_JOIN_TIME and p.afkTime + AFK_TIMEOUT > leveltime then
|
||||
if cv_teamchange.value then
|
||||
allowJoin(false)
|
||||
end
|
||||
elseif p.afkTime + AFK_TIMEOUT < leveltime then
|
||||
if not cv_teamchange.value then
|
||||
allowJoin(true)
|
||||
end
|
||||
end
|
||||
|
||||
@ -1313,17 +1290,11 @@ local function interThink()
|
||||
COM_BufInsertText(server, "map " + nextMap)
|
||||
nextMap = nil
|
||||
end
|
||||
|
||||
if not cv_teamchange then
|
||||
cv_teamchange = CV_FindVar("allowteamchange")
|
||||
end
|
||||
|
||||
if not cv_teamchange.value then
|
||||
if not CV_FindVar("allowteamchange").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)
|
||||
|
Loading…
Reference in New Issue
Block a user