Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
bc002667c8 | |||
b0d5b5abeb | |||
18a81fab6d | |||
9a1fb0677a |
@ -7,6 +7,7 @@ local disable = true
|
||||
local prevLap = 0
|
||||
local splits = {}
|
||||
local PATCH = nil
|
||||
local help = true
|
||||
|
||||
local Flags = 0
|
||||
|
||||
@ -91,42 +92,90 @@ else
|
||||
print("Failed to open file: ", FILENAME)
|
||||
end
|
||||
|
||||
local function initLeaderboard(player)
|
||||
local ingame = 0
|
||||
local function ingame()
|
||||
local n = 0
|
||||
for p in players.iterate do
|
||||
if p.valid and not p.spectator then
|
||||
ingame = ingame + 1
|
||||
n = $ + 1
|
||||
end
|
||||
end
|
||||
|
||||
disable = ingame > 1
|
||||
return n
|
||||
end
|
||||
|
||||
if disable then
|
||||
--print("To many players in game, leaderboard has been disabled")
|
||||
return
|
||||
end
|
||||
local function initLeaderboard(player)
|
||||
disable = ingame() > 1
|
||||
end
|
||||
addHook("PlayerSpawn", initLeaderboard)
|
||||
|
||||
local function retry(player, ...)
|
||||
local function doyoudare(player)
|
||||
if disable or player.spectator then
|
||||
CONS_Printf(player, "How dare you")
|
||||
return
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
COM_BufInsertText(server, "map " + G_BuildMapName(gamemap))
|
||||
local function retry(player, ...)
|
||||
if doyoudare(player) then
|
||||
COM_BufInsertText(server, "map " + G_BuildMapName(gamemap))
|
||||
end
|
||||
end
|
||||
COM_AddCommand("retry", retry)
|
||||
|
||||
local function exitlevel(player, ...)
|
||||
if disable or player.spectator then
|
||||
CONS_Printf(player, "How dare you")
|
||||
return
|
||||
if doyoudare(player) then
|
||||
G_ExitLevel()
|
||||
end
|
||||
G_ExitLevel()
|
||||
end
|
||||
COM_AddCommand("exit", exitlevel)
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
local map = ...
|
||||
if map == nil then
|
||||
CONS_Printf(player, "Usage: changelevel MAPXX")
|
||||
return
|
||||
end
|
||||
|
||||
local p, q = map:upper():match("MAP(%w)(%w)$", 1)
|
||||
if not (p and q) then
|
||||
CONS_Printf(player, string.format("Invalid map name: %s", map))
|
||||
return
|
||||
end
|
||||
|
||||
local mapnum = 0
|
||||
if tonumber(p) != nil then
|
||||
-- Non extended map numbers
|
||||
if tonumber(q) == nil then
|
||||
mapNotExists(player, map)
|
||||
return
|
||||
end
|
||||
mapnum = tonumber(p) * 10 + tonumber(q)
|
||||
else
|
||||
--Extended map numbers
|
||||
p = ALPH:find(p) - 1
|
||||
q = (tonumber(q) or ALPH:find(q) + 9)
|
||||
mapnum = 36 * p + q + 100
|
||||
end
|
||||
|
||||
if mapheaderinfo[mapnum] == nil then
|
||||
mapNotExists(player, map)
|
||||
return
|
||||
end
|
||||
|
||||
COM_BufInsertText(server, "map " + (G_BuildMapName(mapnum)))
|
||||
end
|
||||
COM_AddCommand("changelevel", changelevel)
|
||||
|
||||
local function clearcheats(player)
|
||||
if not player.spectator then
|
||||
clearcheats = true
|
||||
@ -421,6 +470,7 @@ end
|
||||
|
||||
local function think()
|
||||
if disable then
|
||||
help = true
|
||||
return
|
||||
end
|
||||
if showSplit > 0 then
|
||||
@ -428,6 +478,18 @@ local function think()
|
||||
end
|
||||
|
||||
if leveltime < startTime then
|
||||
-- Help message
|
||||
if leveltime == startTime - TICRATE * 3 then
|
||||
if ingame() == 1 then
|
||||
if help then
|
||||
help = false
|
||||
chatprint("\x89Leaderboard Commands:\nretry exit findmap changelevel spba_clearcheats", true)
|
||||
end
|
||||
else
|
||||
help = true
|
||||
end
|
||||
end
|
||||
|
||||
Flags = $ & !(F_SPBATK | F_SPBEXP | F_SPBBIG | F_SPBJUS)
|
||||
if leveltime > startTime - (3 * TICRATE) / 2 and server.SPBArunning then
|
||||
Flags = $ | F_SPBATK
|
||||
|
Reference in New Issue
Block a user