123
This commit is contained in:
1 parent
1d667306da
commit
11d5404f8f
7 files changed
+176
-84
No files matched your search
@@ -40,6 +40,7 @@ remote.Name = "HostedArenaRemote"
|
||||
remote:SetAttribute("IsHosted", hosted)
|
||||
remote:SetAttribute("LocalPublicPreview", localPreview)
|
||||
local previewOwner: Player? = nil
|
||||
local configuringPreview = false
|
||||
local parties: {[Player]: Party} = {}
|
||||
local invitations: {[Player]: Party} = {}
|
||||
local transfers: {[Player]: Transfer} = {}
|
||||
@@ -83,14 +84,19 @@ local function createLocalPublic(player: Player, options: RoundOptions)
|
||||
fail(player, "На этом тестовом сервере уже есть публичная арена. Откройте её карточку.")
|
||||
return
|
||||
end
|
||||
if not previewOwner then
|
||||
if not configureRound(options) then
|
||||
fail(player, "Дождитесь, пока тестовая арена освободится.")
|
||||
return
|
||||
end
|
||||
if not present(player) then return end
|
||||
setPreviewOwner(player)
|
||||
if configuringPreview then
|
||||
fail(player, "Тестовая арена уже готовится.")
|
||||
return
|
||||
end
|
||||
configuringPreview = true
|
||||
local ok, configured = pcall(configureRound, options)
|
||||
configuringPreview = false
|
||||
if not ok or not configured then
|
||||
fail(player, "Дождитесь, пока тестовая арена освободится.")
|
||||
return
|
||||
end
|
||||
if not inLobby(player) then return end
|
||||
setPreviewOwner(player)
|
||||
send(player, "LocalPublicReady")
|
||||
end
|
||||
|
||||
@@ -404,16 +410,34 @@ remote.OnServerEvent:Connect(function(player: Player, action: unknown, value: un
|
||||
if action == "CreatePublic" then launch(player, nil, "Public", options) else invite(player, value, options) end
|
||||
end)
|
||||
|
||||
Players.PlayerRemoving:Connect(function(player)
|
||||
if previewOwner == player then
|
||||
local successor: Player? = nil
|
||||
for _, other in Players:GetPlayers() do
|
||||
if other ~= player and other:GetAttribute("ArenaTeam") ~= nil and Modes.of(other) == Modes.Procedural then
|
||||
successor = other
|
||||
break
|
||||
end
|
||||
local function releasePreviewSeat(leaving: Player)
|
||||
if not previewOwner then return end
|
||||
local successor: Player? = nil
|
||||
for _, other in Players:GetPlayers() do
|
||||
if other ~= leaving and other:GetAttribute("ArenaTeam") ~= nil then
|
||||
if other == previewOwner then return end
|
||||
successor = successor or other
|
||||
end
|
||||
setPreviewOwner(successor)
|
||||
end
|
||||
setPreviewOwner(successor)
|
||||
end
|
||||
|
||||
if localPreview then
|
||||
local function watchPreviewSeat(player: Player)
|
||||
local hadSeat = player:GetAttribute("ArenaTeam") ~= nil
|
||||
player:GetAttributeChangedSignal("ArenaTeam"):Connect(function()
|
||||
local hasSeat = player:GetAttribute("ArenaTeam") ~= nil
|
||||
if hadSeat and not hasSeat then releasePreviewSeat(player) end
|
||||
hadSeat = hasSeat
|
||||
end)
|
||||
end
|
||||
Players.PlayerAdded:Connect(watchPreviewSeat)
|
||||
for _, player in Players:GetPlayers() do watchPreviewSeat(player) end
|
||||
end
|
||||
|
||||
Players.PlayerRemoving:Connect(function(player)
|
||||
if previewOwner == player or player:GetAttribute("ArenaTeam") ~= nil then
|
||||
releasePreviewSeat(player)
|
||||
end
|
||||
lastAction[player], lastCreate[player], lastList[player], transfers[player] = nil, nil, nil, nil
|
||||
lastDetails[player], moreFrom[player] = nil, nil
|
||||
@@ -427,7 +451,12 @@ Players.PlayerRemoving:Connect(function(player)
|
||||
end)
|
||||
|
||||
if hosted then
|
||||
local admission = script.Parent:WaitForChild("ArenaRounds"):WaitForChild("HostedArenaAdmission") :: BindableEvent
|
||||
local rounds = script.Parent:WaitForChild("ArenaRounds")
|
||||
local admission = rounds:WaitForChild("HostedArenaAdmission") :: BindableEvent
|
||||
local exit = rounds:WaitForChild("HostedArenaExit") :: BindableEvent
|
||||
exit.Event:Connect(function(player: Player)
|
||||
if inLobby(player) and not transfers[player] then transfer({player}) end
|
||||
end)
|
||||
local match = ReplicatedStorage:WaitForChild("ArenaRound"):WaitForChild("Procedural")
|
||||
local reservationId = game.PrivateServerId
|
||||
local session: Session? = nil
|
||||
|
||||
Reference in new issue
Block a user