forked from Not/srb2k-leaderboard
change ingame() to only check if there is 2 players in game
as ingame() is only used to check if there is more than 1 player then it is changed to not look for more than 2 since its not needed. name changed to reflect that.
This commit is contained in:
parent
405a0e50f2
commit
906444ae08
@ -310,22 +310,25 @@ function allowJoin(v)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function ingame()
|
local function 2PlusInGame()
|
||||||
local n = 0
|
local n = 0
|
||||||
for p in players.iterate do
|
for p in players.iterate do
|
||||||
if p.valid and not p.spectator then
|
if p.valid and not p.spectator then
|
||||||
n = $ + 1
|
n = $ + 1
|
||||||
|
if n == 2 then
|
||||||
|
return true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return n
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local function initLeaderboard(player)
|
local function initLeaderboard(player)
|
||||||
if cv_enable.value and G_RaceGametype() then
|
if cv_enable.value and G_RaceGametype() then
|
||||||
if disable and leveltime < START_TIME then
|
if disable and leveltime < START_TIME then
|
||||||
disable = ingame() > 1
|
disable = 2PlusInGame()
|
||||||
else
|
else
|
||||||
disable = $ or ingame() > 1
|
disable = $ or 2PlusInGame()
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
disable = true
|
disable = true
|
||||||
@ -342,7 +345,7 @@ end
|
|||||||
addHook("PlayerSpawn", initLeaderboard)
|
addHook("PlayerSpawn", initLeaderboard)
|
||||||
|
|
||||||
local function doyoudare(player)
|
local function doyoudare(player)
|
||||||
if ingame() > 1 or player.spectator then
|
if 2PlusInGame() or player.spectator then
|
||||||
CONS_Printf(player, "How dare you")
|
CONS_Printf(player, "How dare you")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -1163,7 +1166,7 @@ local function think()
|
|||||||
|
|
||||||
if disable then
|
if disable then
|
||||||
if AntiAFK then
|
if AntiAFK then
|
||||||
if ingame() > 1 then
|
if 2PlusInGame() then
|
||||||
for p in players.iterate do
|
for p in players.iterate do
|
||||||
if p.valid and not p.spectator and not p.exiting and p.lives > 0 then
|
if p.valid and not p.spectator and not p.exiting and p.lives > 0 then
|
||||||
if p.cmd.buttons then
|
if p.cmd.buttons then
|
||||||
|
Loading…
Reference in New Issue
Block a user