333
This commit is contained in:
1 parent
82eecfda06
commit
bdf5eca81f
10 files changed
+287
-94
No files matched your search
@@ -197,6 +197,7 @@ local function sendToLobby(player: Player)
|
||||
lastCountedDeath[player] = nil
|
||||
moveToLobby(player)
|
||||
player:SetAttribute("ArenaWaiting", nil)
|
||||
player:SetAttribute("ArenaIntermission", nil)
|
||||
player:SetAttribute("ArenaMode", nil)
|
||||
player:SetAttribute("ArenaTeam", nil)
|
||||
player:SetAttribute("RoundKills", 0)
|
||||
@@ -234,6 +235,17 @@ local function deploy(player: Player)
|
||||
end
|
||||
end
|
||||
|
||||
local function stageOnArena(player: Player)
|
||||
placedCharacter[player] = nil
|
||||
player:SetAttribute("InArena", true)
|
||||
player.RespawnLocation = destinationFor(player)
|
||||
local character = player.Character
|
||||
clearTools(character)
|
||||
clearTools(player:FindFirstChildOfClass("Backpack"))
|
||||
clearTools(player:FindFirstChild("StarterGear"))
|
||||
return character
|
||||
end
|
||||
|
||||
local function enterRound(player: Player, match: Match)
|
||||
if match.rule == "OneLife" then bench(player) else deploy(player) end
|
||||
end
|
||||
@@ -265,7 +277,11 @@ local function onCharacter(player: Player, character: Model)
|
||||
end
|
||||
end)
|
||||
if roster[player] and player:GetAttribute("InArena") == true then
|
||||
enterArena(player, character, humanoid)
|
||||
if player:GetAttribute("ArenaIntermission") == true or player:GetAttribute("ArenaWaiting") == true then
|
||||
ArenaSpawns.place(character, destinationFor(player))
|
||||
else
|
||||
enterArena(player, character, humanoid)
|
||||
end
|
||||
else
|
||||
ArenaSpawns.place(character, lobbySpawn)
|
||||
end
|
||||
@@ -309,7 +325,7 @@ end
|
||||
local function broadcastVotes(match: Match)
|
||||
local counts, total = voteTotals(match)
|
||||
for player in match.eligible do
|
||||
if player.Parent == Players and not roster[player] then
|
||||
if player.Parent == Players then
|
||||
vote:FireClient(player, match.id, match.endsAt, counts, total, match.ballots[player])
|
||||
end
|
||||
end
|
||||
@@ -381,6 +397,10 @@ end
|
||||
|
||||
leave.OnServerEvent:Connect(function(player: Player)
|
||||
if not roster[player] or player:GetAttribute("InArena") ~= true then return end
|
||||
local match = matches[Modes.of(player)]
|
||||
if match.phase ~= "Round" then return end
|
||||
local root = player.Character and player.Character.PrimaryPart
|
||||
if match.engine then match.engine.leaving(player, root and root.Position, workspace:GetServerTimeNow()) end
|
||||
sendToLobby(player)
|
||||
end)
|
||||
|
||||
@@ -467,7 +487,7 @@ end
|
||||
vote.OnServerEvent:Connect(function(player: Player, arena: unknown, id: unknown)
|
||||
if typeof(arena) ~= "string" then return end
|
||||
local match, rule = matches[arena], Rules.find(id)
|
||||
if not match or not rule or not match.eligible[player] or roster[player] then return end
|
||||
if not match or not rule or not match.eligible[player] then return end
|
||||
local now = workspace:GetServerTimeNow()
|
||||
if not votingOpen(match, now) or now - (lastVote[player] or -math.huge) < .18 or match.ballots[player] == rule.id then return end
|
||||
lastVote[player] = now
|
||||
@@ -513,8 +533,12 @@ local function returnVoters(match: Match)
|
||||
local returning: {Player} = {}
|
||||
for _, player in Players:GetPlayers() do
|
||||
local previousSide = match.eligible[player]
|
||||
if previousSide and match.ballots[player] and not roster[player] then
|
||||
if previousSide and (not match.allowModeChange or match.ballots[player]) then
|
||||
assignTeam(player, match, previousSide)
|
||||
player:SetAttribute("RoundKills", 0)
|
||||
player:SetAttribute("RoundDeaths", 0)
|
||||
lastCountedDeath[player] = nil
|
||||
resetStreak(player)
|
||||
table.insert(returning, player)
|
||||
end
|
||||
end
|
||||
@@ -523,7 +547,20 @@ local function returnVoters(match: Match)
|
||||
if #returning == 0 then return end
|
||||
|
||||
balanceWaiting(match)
|
||||
for _, player in returning do enterRound(player, match) end
|
||||
for _, player in returning do
|
||||
if match.rule == "OneLife" then
|
||||
player:SetAttribute("ArenaWaiting", true)
|
||||
local character = stageOnArena(player)
|
||||
local humanoid = character and character:FindFirstChildOfClass("Humanoid")
|
||||
if character and humanoid and humanoid.Health > 0 then
|
||||
humanoid.Health = humanoid.MaxHealth
|
||||
ArenaSpawns.place(character, destinationFor(player))
|
||||
end
|
||||
else
|
||||
deploy(player)
|
||||
end
|
||||
player:SetAttribute("ArenaIntermission", nil)
|
||||
end
|
||||
end
|
||||
|
||||
local function startRound(match: Match)
|
||||
@@ -627,8 +664,15 @@ local function finishRound(match: Match)
|
||||
publish(match)
|
||||
for _, entry in participants do
|
||||
local player = entry.player
|
||||
sendToLobby(player)
|
||||
match.eligible[player] = entry.side
|
||||
player:SetAttribute("ArenaIntermission", true)
|
||||
local wasInArena = player:GetAttribute("InArena") == true
|
||||
player:SetAttribute("ArenaWaiting", nil)
|
||||
local character = stageOnArena(player)
|
||||
local humanoid = character and character:FindFirstChildOfClass("Humanoid")
|
||||
if not wasInArena and character and humanoid and humanoid.Health > 0 then
|
||||
ArenaSpawns.place(character, destinationFor(player))
|
||||
end
|
||||
results:FireClient(player, snapshot, entry.side)
|
||||
end
|
||||
if engine then engine.destroy() end
|
||||
@@ -657,12 +701,13 @@ local function finishVote(match: Match, now: number)
|
||||
publish(match)
|
||||
local outcome = {winner = match.rule, endsAt = match.endsAt}
|
||||
for player in match.eligible do
|
||||
if player.Parent == Players and not roster[player] then
|
||||
vote:FireClient(player, match.id, ballotDeadline, counts, total, match.ballots[player], outcome)
|
||||
if player.Parent == Players then
|
||||
local selection = match.ballots[player]
|
||||
vote:FireClient(player, match.id, ballotDeadline, counts, total, selection, outcome)
|
||||
if not selection then sendToLobby(player) end
|
||||
end
|
||||
end
|
||||
end
|
||||
if match.phase == "Reveal" then return end
|
||||
match.phase = "Setup"
|
||||
startRound(match)
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user