forked from Not/srb2k-leaderboard
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
b0d5b5abeb | |||
18a81fab6d | |||
9a1fb0677a | |||
321ff7737c |
@ -7,6 +7,7 @@ local disable = true
|
|||||||
local prevLap = 0
|
local prevLap = 0
|
||||||
local splits = {}
|
local splits = {}
|
||||||
local PATCH = nil
|
local PATCH = nil
|
||||||
|
local help = true
|
||||||
|
|
||||||
local Flags = 0
|
local Flags = 0
|
||||||
|
|
||||||
@ -101,32 +102,83 @@ local function initLeaderboard(player)
|
|||||||
|
|
||||||
disable = ingame > 1
|
disable = ingame > 1
|
||||||
|
|
||||||
if disable then
|
if disable or ingame == 0 then
|
||||||
--print("To many players in game, leaderboard has been disabled")
|
-- Print the help message next time someone is alone
|
||||||
|
help = true
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
addHook("PlayerSpawn", initLeaderboard)
|
addHook("PlayerSpawn", initLeaderboard)
|
||||||
|
|
||||||
local function retry(player, ...)
|
local function doyoudare(player)
|
||||||
if disable or player.spectator then
|
if disable or player.spectator then
|
||||||
CONS_Printf(player, "How dare you")
|
CONS_Printf(player, "How dare you")
|
||||||
return
|
return false
|
||||||
end
|
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
|
end
|
||||||
COM_AddCommand("retry", retry)
|
COM_AddCommand("retry", retry)
|
||||||
|
|
||||||
local function exitlevel(player, ...)
|
local function exitlevel(player, ...)
|
||||||
if disable or player.spectator then
|
if doyoudare(player) then
|
||||||
CONS_Printf(player, "How dare you")
|
G_ExitLevel()
|
||||||
return
|
|
||||||
end
|
end
|
||||||
G_ExitLevel()
|
|
||||||
end
|
end
|
||||||
COM_AddCommand("exit", exitlevel)
|
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)
|
local function clearcheats(player)
|
||||||
if not player.spectator then
|
if not player.spectator then
|
||||||
clearcheats = true
|
clearcheats = true
|
||||||
@ -186,6 +238,17 @@ local function drawitem(v, x, y, scale, itempatch, vflags)
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function marquee(text, maxwidth)
|
||||||
|
if #text <= maxwidth then
|
||||||
|
return text
|
||||||
|
end
|
||||||
|
|
||||||
|
local shift = 16
|
||||||
|
local pos = ((leveltime / 16) % (#text - maxwidth + shift * 2)) + 1 - shift
|
||||||
|
pos = min(max(pos, 1), #text - maxwidth + 1)
|
||||||
|
return text:sub(pos, pos + maxwidth - 1)
|
||||||
|
end
|
||||||
|
|
||||||
local bodium = {V_YELLOWMAP, V_GRAYMAP, V_BROWNMAP, 0}
|
local bodium = {V_YELLOWMAP, V_GRAYMAP, V_BROWNMAP, 0}
|
||||||
local splitColor = {[true]=V_SKYMAP, [false]=V_REDMAP}
|
local splitColor = {[true]=V_SKYMAP, [false]=V_REDMAP}
|
||||||
local splitSymbol = {[true]="-", [false]="+"}
|
local splitSymbol = {[true]="-", [false]="+"}
|
||||||
@ -273,7 +336,7 @@ local function drawScoreboard(v, player)
|
|||||||
stralign = "small"
|
stralign = "small"
|
||||||
py = 2
|
py = 2
|
||||||
if v.stringWidth(name, 0, "small") > MAXWIDTH then
|
if v.stringWidth(name, 0, "small") > MAXWIDTH then
|
||||||
name = name:sub(0, 15) + "..."
|
name = marquee(name, 15)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -417,6 +480,12 @@ local function think()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if leveltime < startTime then
|
if leveltime < startTime then
|
||||||
|
-- Help message
|
||||||
|
if help and leveltime == startTime - TICRATE * 3 then
|
||||||
|
help = false
|
||||||
|
chatprint("\x89Leaderboard Commands:\nretry exit findmap changelevel spba_clearcheats", true)
|
||||||
|
end
|
||||||
|
|
||||||
Flags = $ & !(F_SPBATK | F_SPBEXP | F_SPBBIG | F_SPBJUS)
|
Flags = $ & !(F_SPBATK | F_SPBEXP | F_SPBBIG | F_SPBJUS)
|
||||||
if leveltime > startTime - (3 * TICRATE) / 2 and server.SPBArunning then
|
if leveltime > startTime - (3 * TICRATE) / 2 and server.SPBArunning then
|
||||||
Flags = $ | F_SPBATK
|
Flags = $ | F_SPBATK
|
||||||
|
Reference in New Issue
Block a user