923 lines
40 KiB
Luau
923 lines
40 KiB
Luau
--!strict
|
||
local Text = require(game:GetService("ReplicatedStorage"):WaitForChild("Hunter"):WaitForChild("Strings") :: ModuleScript).interface.HostedArenaHud
|
||
|
||
local GuiService = game:GetService("GuiService")
|
||
local Players = game:GetService("Players")
|
||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||
local RunService = game:GetService("RunService")
|
||
local TweenService = game:GetService("TweenService")
|
||
local UserInputService = game:GetService("UserInputService")
|
||
local UI = require(ReplicatedStorage:WaitForChild("HunterUI") :: ModuleScript)
|
||
local Hosting = require(ReplicatedStorage:WaitForChild("HostedArena") :: ModuleScript)
|
||
local Modes = require(ReplicatedStorage:WaitForChild("ArenaModes") :: ModuleScript)
|
||
local Rules = require(ReplicatedStorage:WaitForChild("MatchRules") :: ModuleScript)
|
||
local ModeCard = require(ReplicatedStorage:WaitForChild("ModeCard") :: ModuleScript)
|
||
local roundState = ReplicatedStorage:WaitForChild("ArenaRound")
|
||
local join = roundState:WaitForChild("JoinTeam") :: RemoteEvent
|
||
local remote = ReplicatedStorage:WaitForChild("HostedArenaRemote") :: RemoteEvent
|
||
local hosted = remote:GetAttribute("IsHosted") == true
|
||
local localPreview = remote:GetAttribute("LocalPublicPreview") == true
|
||
local player = Players.LocalPlayer
|
||
local pg = player:WaitForChild("PlayerGui")
|
||
local roundHud = pg:WaitForChild("ArenaRoundHud")
|
||
|
||
type Invite = {id: string, hostId: number, hostName: string, hostUsername: string, expires: number}
|
||
type Party = {accepted: number, pending: number, expires: number}
|
||
type Listing = Hosting.Listing
|
||
type Details = Hosting.Details
|
||
type Side = Hosting.Side
|
||
type Choice = {id: string, name: string, mode: string?, hostId: number?, players: number, ruleset: string}
|
||
type ArenaCard = {choice: Choice, visual: ModeCard.Card, name: TextLabel}
|
||
|
||
local violet = Color3.fromRGB(178, 133, 255)
|
||
local dark = Color3.fromRGB(17, 23, 38)
|
||
local gui = Instance.new("ScreenGui")
|
||
gui.Name = "HostedArenaHud"
|
||
gui.ResetOnSpawn = false
|
||
gui.DisplayOrder = 38
|
||
gui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
|
||
gui.Parent = pg
|
||
|
||
local function button(parent: Instance, name: string, value: string, position: UDim2, size: UDim2, accent: Color3, primary: boolean?): TextButton
|
||
local item = Instance.new("TextButton")
|
||
item.Name, item.Position, item.Size = name, position, size
|
||
item.BackgroundColor3 = if primary then accent else dark:Lerp(accent, .17)
|
||
item.BorderSizePixel = 0
|
||
item.Text, item.TextSize = value, 15
|
||
item.TextColor3 = if primary then dark else UI.Ink
|
||
item.FontFace = UI.Display
|
||
item.Parent = parent
|
||
UI.bindButton(item, accent)
|
||
return item
|
||
end
|
||
|
||
local function leftLabel(parent: Instance, name: string, value: string, x: number, y: number, w: number, h: number, size: number, color: Color3): TextLabel
|
||
local text = UI.label(parent, name, value, UDim2.fromOffset(x, y), UDim2.fromOffset(w, h), size, color)
|
||
text.TextXAlignment = Enum.TextXAlignment.Left
|
||
text.TextTruncate = Enum.TextTruncate.AtEnd
|
||
return text
|
||
end
|
||
|
||
local function showAvatar(image: ImageLabel, userId: number, name: string)
|
||
local initial = image:FindFirstChild("Initial") :: TextLabel?
|
||
if initial then
|
||
initial.Text = if name == "" then "?" else name:sub(1, (utf8.offset(name, 2) or #name + 1) - 1)
|
||
initial.Visible = true
|
||
end
|
||
image.Image = if userId > 0 then "rbxthumb://type=AvatarHeadShot&id=" .. userId .. "&w=150&h=150" else ""
|
||
if initial then
|
||
local function update() initial.Visible = image.Image == "" or not image.IsLoaded end
|
||
if not image:GetAttribute("TracksLoading") then
|
||
image:SetAttribute("TracksLoading", true)
|
||
image:GetPropertyChangedSignal("IsLoaded"):Connect(update)
|
||
end
|
||
update()
|
||
end
|
||
end
|
||
|
||
local rowGap = 6
|
||
local function makeList(parent: Instance, name: string, position: UDim2, size: UDim2, accent: Color3): ScrollingFrame
|
||
local scroll = Instance.new("ScrollingFrame")
|
||
scroll.Name, scroll.Position, scroll.Size = name, position, size
|
||
scroll.BackgroundTransparency, scroll.BorderSizePixel = 1, 0
|
||
scroll.ScrollBarThickness, scroll.ScrollBarImageColor3 = 5, accent
|
||
scroll.ScrollingDirection = Enum.ScrollingDirection.Y
|
||
scroll.CanvasSize, scroll.AutomaticCanvasSize = UDim2.new(), Enum.AutomaticSize.Y
|
||
local layout = Instance.new("UIListLayout", scroll)
|
||
layout.Padding, layout.SortOrder = UDim.new(0, rowGap), Enum.SortOrder.LayoutOrder
|
||
scroll.Parent = parent
|
||
return scroll
|
||
end
|
||
|
||
local launch = button(gui, "OpenArenaCreator", if hosted then Text.vObscheeLobbi else Text.sozdatArenu,
|
||
UDim2.new(1, -24, 1, -42), UDim2.fromOffset(264, 52), violet, true)
|
||
launch.AnchorPoint = Vector2.new(1, 1)
|
||
launch.Modal = true
|
||
|
||
local browser = UI.plate(gui, "PublicArenas", UDim2.new(1, -24, 1, -104), UDim2.fromOffset(264, 432), UI.Blue, dark)
|
||
browser.AnchorPoint = Vector2.new(1, 1)
|
||
local browserTitle = leftLabel(browser, "Heading", if hosted then Text.arenaSessii else Text.publichnyeAreny, 13, 7, 173, 34, 16, UI.Ink)
|
||
browserTitle.FontFace = UI.Display
|
||
local ownerLabel = leftLabel(browser, "Owner", "", 13, 38, 237, 21, 12, UI.Muted)
|
||
ownerLabel.Visible = hosted
|
||
local refreshDirectory = button(browser, "Refresh", Text.obnovit, UDim2.fromOffset(191, 9), UDim2.fromOffset(61, 31), UI.Blue)
|
||
refreshDirectory.TextSize = 10
|
||
refreshDirectory.Visible = not hosted and not localPreview
|
||
local listTop = if hosted then 64 else 47
|
||
local cardHeight, moreHeight = 184, 37
|
||
local browserChrome = listTop + 10
|
||
local contentHeight = cardHeight
|
||
local arenaList = makeList(browser, "List", UDim2.fromOffset(10, listTop), UDim2.new(0, 244, 1, -browserChrome), UI.Blue)
|
||
local moreArenas = button(arenaList, "More", Text.pokazatEschyo, UDim2.new(), UDim2.new(1, -13, 0, moreHeight), UI.Blue)
|
||
moreArenas.Visible = false
|
||
|
||
local shade = UI.frame("CreatorShade", gui, UDim2.fromScale(0, 0), UDim2.fromScale(1, 1), Color3.fromRGB(5, 10, 20))
|
||
shade.BackgroundTransparency, shade.Active, shade.Visible = .2, true, false
|
||
local dialogWidth, createHeight, detailsHeight = 642, 685, 461
|
||
local currentHeight = createHeight
|
||
local panel = UI.plate(shade, "Creator", UDim2.fromScale(.5, .5), UDim2.fromOffset(dialogWidth, createHeight), violet, dark)
|
||
panel.AnchorPoint = Vector2.new(.5, .5)
|
||
UI.contour(panel, violet)
|
||
local panelScale = Instance.new("UIScale", panel)
|
||
local function fit()
|
||
local screen = shade.AbsoluteSize
|
||
panelScale.Scale = math.clamp(math.min((screen.X - 24) / dialogWidth, (screen.Y - 24) / currentHeight), .05, 1)
|
||
local maximum = math.clamp(screen.Y - 204, 210, 432)
|
||
local desired = browserChrome + contentHeight
|
||
browser.Size = UDim2.fromOffset(264, math.min(desired, maximum))
|
||
local scrollable = desired > maximum
|
||
arenaList.ScrollingEnabled = scrollable
|
||
arenaList.ScrollBarImageTransparency = if scrollable then 0 else 1
|
||
if not scrollable then arenaList.CanvasPosition = Vector2.zero end
|
||
end
|
||
shade:GetPropertyChangedSignal("AbsoluteSize"):Connect(fit)
|
||
fit()
|
||
|
||
local header = leftLabel(panel, "Title", Text.sozdanieAreny, 26, 15, 520, 45, 31, UI.Ink)
|
||
header.FontFace = UI.Display
|
||
local close = button(panel, "Close", "×", UDim2.fromOffset(568, 19), UDim2.fromOffset(48, 37), UI.Orange)
|
||
close.TextSize, close.Modal = 23, true
|
||
local public = button(panel, "Public", Text.publichnaya, UDim2.fromOffset(26, 74), UDim2.fromOffset(284, 44), UI.Blue)
|
||
local private = button(panel, "Private", Text.privatnaya, UDim2.fromOffset(322, 74), UDim2.fromOffset(294, 44), violet)
|
||
local explanation = leftLabel(panel, "Description", "", 26, 129, 590, 28, 14, UI.Muted)
|
||
local modesHeading = leftLabel(panel, "ModesHeading", Text.startovyyRezhim, 26, 154, 590, 25, 15, UI.Ink)
|
||
modesHeading.FontFace = UI.Display
|
||
local modeChoices = UI.frame("InitialModeChoices", panel, UDim2.fromOffset(26, 184), UDim2.fromOffset(590, 174), dark)
|
||
modeChoices.BackgroundTransparency = 1
|
||
local modeCards: {[string]: ModeCard.Card} = {}
|
||
for index, rule in Rules.All do
|
||
local column, row = (index - 1) % 4, (index - 1) // 4
|
||
local card = ModeCard.new(modeChoices, rule.id, UDim2.fromOffset(column * 149, row * 90), UDim2.fromOffset(143, 84), true)
|
||
card.badgePanel.Visible = false
|
||
card.title.Position = UDim2.new(0, 6, 1, -31)
|
||
card.title.Size = UDim2.new(1, -12, 0, 25)
|
||
card.art.Size = UDim2.new(1, -12, 1, -35)
|
||
modeCards[rule.id] = card
|
||
end
|
||
local modeDescription = leftLabel(panel, "ModeDescription", "", 26, 361, 590, 24, 13, UI.Muted)
|
||
local changeLabel = leftLabel(panel, "ModeChangeHeading", Text.razreshitSmenuRezhimov, 26, 391, 375, 22, 16, UI.Ink)
|
||
changeLabel.FontFace = UI.Display
|
||
local changeHint = leftLabel(panel, "ModeChangeHint", "", 26, 413, 375, 20, 12, UI.Muted)
|
||
local changeToggle = button(panel, "AllowModeChange", "", UDim2.fromOffset(430, 391), UDim2.fromOffset(186, 41), UI.Mint, true)
|
||
local selectionCount = leftLabel(panel, "Selection", "", 26, 441, 590, 24, 13, violet)
|
||
local list = makeList(panel, "ServerPlayers", UDim2.fromOffset(26, 471), UDim2.fromOffset(590, 123), violet)
|
||
local status = leftLabel(panel, "Status", "", 26, 598, 590, 28, 14, UI.Muted)
|
||
local action = button(panel, "Submit", "", UDim2.fromOffset(26, 626), UDim2.fromOffset(590, 42), violet, true)
|
||
|
||
local detailsPanel = UI.plate(shade, "ArenaDetails", UDim2.fromScale(.5, .5), UDim2.fromOffset(dialogWidth, detailsHeight), UI.Blue, dark)
|
||
detailsPanel.AnchorPoint, detailsPanel.Visible = Vector2.new(.5, .5), false
|
||
UI.contour(detailsPanel, UI.Blue)
|
||
local detailsScale = Instance.new("UIScale", detailsPanel)
|
||
local detailsTitle = leftLabel(detailsPanel, "Title", "", 26, 15, 520, 46, 27, UI.Ink)
|
||
detailsTitle.FontFace = UI.Display
|
||
local detailsClose = button(detailsPanel, "Close", "×", UDim2.fromOffset(568, 19), UDim2.fromOffset(48, 37), UI.Orange)
|
||
detailsClose.TextSize, detailsClose.Modal = 23, true
|
||
local detailsStatus = leftLabel(detailsPanel, "Status", "", 26, 357, 590, 32, 14, UI.Muted)
|
||
local connect = button(detailsPanel, "Connect", Text.podklyuchitSya, UDim2.fromOffset(26, 397), UDim2.fromOffset(590, 43), UI.Blue, true)
|
||
|
||
local function teamColumn(name: string, text: string, x: number, accent: Color3)
|
||
local body = UI.plate(detailsPanel, name, UDim2.fromOffset(x + 144.5, 212), UDim2.fromOffset(289, 274), accent, dark:Lerp(accent, .08))
|
||
body.AnchorPoint = Vector2.new(.5, .5)
|
||
local zoom = Instance.new("UIScale", body)
|
||
local glow = UI.frame("SelectionGlow", body, UDim2.fromOffset(3, 3), UDim2.new(1, -6, 1, -6), accent)
|
||
glow.BackgroundTransparency = 1
|
||
local shine = Instance.new("UIGradient", glow)
|
||
shine.Rotation = 24
|
||
shine.Transparency = NumberSequence.new({
|
||
NumberSequenceKeypoint.new(0, .73),
|
||
NumberSequenceKeypoint.new(.48, .18),
|
||
NumberSequenceKeypoint.new(1, .83),
|
||
})
|
||
local border = UI.edge(body, accent, 0)
|
||
local heading = leftLabel(body, "Heading", text, 12, 7, 173, 34, 17, accent)
|
||
heading.FontFace = UI.Display
|
||
local count = UI.label(body, "Count", "", UDim2.fromOffset(188, 8), UDim2.fromOffset(86, 31), 14, UI.Ink)
|
||
local scroll = makeList(body, "Players", UDim2.fromOffset(9, 47), UDim2.fromOffset(271, 177), accent)
|
||
local marker = UI.label(body, "ChoiceLabel", Text.vybrat, UDim2.fromOffset(9, 232), UDim2.fromOffset(271, 32), 13, accent)
|
||
marker.FontFace = UI.Display
|
||
local dimmer = UI.frame("SelectionDimmer", body, UDim2.fromScale(0, 0), UDim2.fromScale(1, 1), dark)
|
||
dimmer.BackgroundTransparency, dimmer.ZIndex = 1, 3
|
||
local hit = Instance.new("TextButton")
|
||
hit.Name = "Choose"
|
||
hit.Size, hit.ZIndex = UDim2.new(1, -14, 1, 0), 4
|
||
hit.Text, hit.BackgroundTransparency, hit.AutoButtonColor = "", 1, false
|
||
hit.Selectable, hit.Parent = true, body
|
||
return {count = count, scroll = scroll, accent = accent, stamp = nil :: string?,
|
||
zoom = zoom, glow = glow, shine = shine, border = border, dimmer = dimmer, hit = hit, marker = marker,
|
||
hovered = false, focused = false, pressed = false, feedbackTween = nil :: Tween?}
|
||
end
|
||
local blueTeam = teamColumn("Blue", Text.sinie, 26, UI.Blue)
|
||
local orangeTeam = teamColumn("Orange", Text.oranzhevye, 327, UI.Orange)
|
||
type TeamColumn = typeof(blueTeam)
|
||
local teamColumns: {[Side]: TeamColumn} = {Blue = blueTeam, Orange = orangeTeam}
|
||
shade:GetPropertyChangedSignal("AbsoluteSize"):Connect(function()
|
||
local screen = shade.AbsoluteSize
|
||
detailsScale.Scale = math.clamp(math.min((screen.X - 24) / dialogWidth, (screen.Y - 24) / detailsHeight), .05, 1)
|
||
end)
|
||
local notice = UI.plate(gui, "Notice", UDim2.new(0, 24, 1, -108), UDim2.fromOffset(380, 44), violet, dark)
|
||
notice.AnchorPoint, notice.Visible = Vector2.new(0, 1), false
|
||
local noticeText = leftLabel(notice, "Text", "", 13, 0, 354, 44, 13, UI.Ink)
|
||
noticeText.TextWrapped = true
|
||
|
||
local invitation = UI.plate(gui, "ArenaInvitation", UDim2.fromOffset(24, 163), UDim2.fromOffset(354, 166), violet, dark)
|
||
invitation.Visible = false
|
||
UI.contour(invitation, violet)
|
||
local inviteTitle = leftLabel(invitation, "Title", Text.priglashenieNaArenu, 14, 7, 282, 27, 17, UI.Ink)
|
||
inviteTitle.FontFace = UI.Display
|
||
local inviteTimer = UI.label(invitation, "Timer", "", UDim2.fromOffset(297, 7), UDim2.fromOffset(44, 27), 14, violet)
|
||
local portrait = UI.portrait(invitation, UDim2.fromOffset(15, 43), 51, violet)
|
||
portrait.Name = "CreatorPortrait"
|
||
local hostLabel = leftLabel(invitation, "CreatorName", "", 78, 42, 261, 24, 17, UI.Ink)
|
||
local hostAccount = leftLabel(invitation, "CreatorAccount", "", 78, 67, 261, 22, 13, UI.Muted)
|
||
local accept = button(invitation, "Accept", Text.prinyatY, UDim2.fromOffset(14, 109), UDim2.fromOffset(156, 41), UI.Mint, true)
|
||
local decline = button(invitation, "Decline", Text.otklonitU, UDim2.fromOffset(181, 109), UDim2.fromOffset(159, 41), violet)
|
||
|
||
local isPrivate = false
|
||
local roundOptions: Hosting.RoundOptions = {initialMode = Rules.Default, allowModeChange = true}
|
||
local selected: {[number]: boolean} = {}
|
||
local rows: {[number]: {button: TextButton, mark: TextLabel}} = {}
|
||
local listings: {Listing} = {}
|
||
local hasMore, listingPending, expandedList = false, false, false
|
||
local lastListRequest, lastDetailRequest = -math.huge, -math.huge
|
||
local arena: Choice? = nil
|
||
local arenaDetails: Details? = nil
|
||
local joinNote: string? = nil
|
||
local preferredSide: Side? = nil
|
||
local confirmedSide: Side? = nil
|
||
local selectionTweens: {Tween} = {}
|
||
local party: Party? = nil
|
||
local currentInvite: Invite? = nil
|
||
local accepted, sending, transferring = false, false, false
|
||
local requestNumber, noticeNumber = 0, 0
|
||
local opening: Tween? = nil
|
||
local clockSecond = -1
|
||
|
||
local function resetTeamReveal()
|
||
confirmedSide = nil
|
||
for _, tween in selectionTweens do tween:Cancel() end
|
||
table.clear(selectionTweens)
|
||
for _, team in {blueTeam, orangeTeam} do
|
||
if team.feedbackTween then team.feedbackTween:Cancel() end
|
||
team.hit:SetAttribute("UIState", nil)
|
||
team.pressed = false
|
||
team.zoom.Scale = 1
|
||
team.glow.BackgroundTransparency, team.dimmer.BackgroundTransparency = 1, 1
|
||
team.border.Transparency, team.border.Thickness = 1, 1.2
|
||
team.shine.Offset = Vector2.zero
|
||
end
|
||
detailsStatus.TextColor3, detailsStatus.TextTransparency = UI.Muted, 0
|
||
end
|
||
|
||
local function showTeamFeedback(team: TeamColumn, side: Side)
|
||
if confirmedSide then return end
|
||
local chosen = preferredSide == side
|
||
local state = if team.pressed then "Pressed" elseif chosen then "Selected"
|
||
elseif not team.hit.Interactable then "Disabled" elseif team.hovered or team.focused then "Hover" else "Normal"
|
||
if team.hit:GetAttribute("UIState") == state then return end
|
||
team.hit:SetAttribute("UIState", state)
|
||
if team.feedbackTween then team.feedbackTween:Cancel() end
|
||
local opacity = if state == "Pressed" then .47 elseif state == "Selected" then .61 elseif state == "Hover" then .77 else 1
|
||
team.border.Transparency = if state == "Selected" or state == "Pressed" then .22 elseif state == "Hover" then .57 else 1
|
||
if GuiService.ReducedMotionEnabled then
|
||
team.glow.BackgroundTransparency = opacity
|
||
else
|
||
team.feedbackTween = TweenService:Create(team.glow, TweenInfo.new(.14, Enum.EasingStyle.Quad),
|
||
{BackgroundTransparency = opacity})
|
||
team.feedbackTween:Play()
|
||
end
|
||
end
|
||
|
||
local function revealTeam(side: Side)
|
||
resetTeamReveal()
|
||
confirmedSide = side
|
||
local chosen = if side == "Blue" then blueTeam else orangeTeam
|
||
local other = if side == "Blue" then orangeTeam else blueTeam
|
||
detailsStatus.TextColor3 = chosen.accent
|
||
if GuiService.ReducedMotionEnabled then
|
||
chosen.glow.BackgroundTransparency, chosen.border.Transparency = .65, .24
|
||
other.dimmer.BackgroundTransparency = .54
|
||
return
|
||
end
|
||
chosen.shine.Offset = Vector2.new(-.6, 0)
|
||
detailsStatus.TextTransparency = .62
|
||
local transition = TweenInfo.new(.29, Enum.EasingStyle.Quart, Enum.EasingDirection.Out)
|
||
local settling = TweenInfo.new(.38, Enum.EasingStyle.Back, Enum.EasingDirection.Out)
|
||
local sweep = TweenInfo.new(.57, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
|
||
selectionTweens = {
|
||
TweenService:Create(chosen.glow, transition, {BackgroundTransparency = .61}),
|
||
TweenService:Create(chosen.border, transition, {Transparency = .18, Thickness = 2.2}),
|
||
TweenService:Create(other.dimmer, transition, {BackgroundTransparency = .52}),
|
||
TweenService:Create(chosen.zoom, settling, {Scale = 1.026}),
|
||
TweenService:Create(chosen.shine, sweep, {Offset = Vector2.new(.48, 0)}),
|
||
TweenService:Create(detailsStatus, transition, {TextTransparency = 0}),
|
||
}
|
||
for _, tween in selectionTweens do tween:Play() end
|
||
end
|
||
|
||
local function refreshLaunch()
|
||
launch.Visible = roundHud:GetAttribute("LobbyAvailable") == true and not shade.Visible and not transferring
|
||
launch.Interactable = not sending
|
||
browser.Visible = launch.Visible
|
||
end
|
||
|
||
local function showNotice(text: string, sticky: boolean?)
|
||
noticeNumber += 1
|
||
local sequence = noticeNumber
|
||
noticeText.Text, notice.Visible = text, text ~= ""
|
||
if text ~= "" and not sticky then
|
||
task.delay(5, function()
|
||
if noticeNumber == sequence then notice.Visible = false end
|
||
end)
|
||
end
|
||
end
|
||
|
||
local function refreshSelection()
|
||
local busy = sending or party ~= nil
|
||
for id, card in modeCards do
|
||
ModeCard.setSelected(card, id == roundOptions.initialMode)
|
||
local input = card.button
|
||
if input then input.Interactable = not busy end
|
||
end
|
||
changeToggle.Interactable = not busy
|
||
local count = 0
|
||
for _ in selected do count += 1 end
|
||
selectionCount.Text = string.format(Text.vybranoDD, count, Hosting.MaxPlayers - 1)
|
||
for id, row in rows do
|
||
local active = selected[id] == true
|
||
row.button.BackgroundColor3 = dark:Lerp(violet, if active then .45 else .15)
|
||
row.button.Interactable = not sending and not party
|
||
row.mark.Text, row.mark.TextColor3 = if active then "✓" else "+", if active then UI.Ink else violet
|
||
end
|
||
action.Interactable = not sending and (party ~= nil or not isPrivate or count > 0)
|
||
action.BackgroundColor3 = if action.Interactable then violet else dark:Lerp(UI.Muted, .18)
|
||
action.TextColor3 = if action.Interactable then dark else UI.Muted
|
||
end
|
||
|
||
local function clearList(scroll: ScrollingFrame)
|
||
for _, child in scroll:GetChildren() do
|
||
if child:IsA("GuiObject") then child:Destroy() end
|
||
end
|
||
end
|
||
|
||
local function request(actionName: string, data: any?, extra: (Side | Hosting.RoundOptions)?)
|
||
if sending or transferring then return end
|
||
sending = true
|
||
requestNumber += 1
|
||
local sequence = requestNumber
|
||
refreshSelection()
|
||
refreshLaunch()
|
||
if actionName == "LocalJoin" then join:FireServer("AutoPreview", data, extra) else remote:FireServer(actionName, data, extra) end
|
||
task.delay(12, function()
|
||
if sequence ~= requestNumber or not sending then return end
|
||
sending = false
|
||
refreshSelection()
|
||
refreshLaunch()
|
||
connect.Interactable = false
|
||
detailsClose.Interactable = true
|
||
resetTeamReveal()
|
||
if shade.Visible then
|
||
local message = Text.otvetZaderzhalsyaPoprobuyteSnova
|
||
if arena then joinNote, detailsStatus.Text = message, message else status.Text = message end
|
||
else showNotice(Text.otvetZaderzhalsyaPoprobuyteSnova) end
|
||
end)
|
||
end
|
||
|
||
local function renderList()
|
||
clearList(list)
|
||
table.clear(rows)
|
||
if not isPrivate then return end
|
||
local available = Players:GetPlayers()
|
||
table.sort(available, function(a, b) return a.DisplayName:lower() < b.DisplayName:lower() end)
|
||
for index, candidate in available do
|
||
if candidate == player then continue end
|
||
local id = candidate.UserId
|
||
local row = button(list, "Select_" .. id, "", UDim2.new(), UDim2.new(1, -10, 0, 46), violet)
|
||
row.LayoutOrder = index
|
||
showAvatar(UI.portrait(row, UDim2.fromOffset(8, 5), 36, violet), id, candidate.DisplayName)
|
||
leftLabel(row, "PlayerName", candidate.DisplayName, 54, 1, 425, 24, 15, UI.Ink)
|
||
leftLabel(row, "Account", "@" .. candidate.Name, 54, 23, 425, 20, 12, UI.Muted)
|
||
local mark = UI.label(row, "SelectedMark", "", UDim2.fromOffset(522, 0), UDim2.fromOffset(46, 46), 24, violet)
|
||
rows[id] = {button = row, mark = mark}
|
||
row.Activated:Connect(function()
|
||
if party or sending then return end
|
||
if not selected[id] then
|
||
local count = 0
|
||
for _ in selected do count += 1 end
|
||
if count >= Hosting.MaxPlayers - 1 then return end
|
||
end
|
||
selected[id] = if selected[id] then nil else true
|
||
refreshSelection()
|
||
end)
|
||
end
|
||
end
|
||
|
||
local function updatePanel()
|
||
local busy = party ~= nil or sending
|
||
local showPlayers = isPrivate and (#Players:GetPlayers() > 1 or party ~= nil)
|
||
local compact = not showPlayers
|
||
currentHeight = if compact then 530 else createHeight
|
||
panel.Size = UDim2.fromOffset(dialogWidth, currentHeight)
|
||
status.Position = UDim2.fromOffset(26, if compact then 443 else 598)
|
||
action.Position = UDim2.fromOffset(26, if compact then 471 else 626)
|
||
fit()
|
||
refreshLaunch()
|
||
public.Interactable, private.Interactable = not busy, not busy
|
||
public.BackgroundColor3 = dark:Lerp(UI.Blue, if isPrivate then .17 else .58)
|
||
private.BackgroundColor3 = dark:Lerp(violet, if isPrivate then .58 else .17)
|
||
selectionCount.Visible, list.Visible = showPlayers, showPlayers
|
||
modeDescription.Text = Rules.get(roundOptions.initialMode).detail
|
||
changeToggle.Text = if roundOptions.allowModeChange then Text.vklyucheno else Text.vyklyucheno
|
||
changeToggle.BackgroundColor3 = if roundOptions.allowModeChange then UI.Mint else dark:Lerp(UI.Muted, .23)
|
||
changeToggle.TextColor3 = if roundOptions.allowModeChange then dark else UI.Ink
|
||
changeHint.Text = if roundOptions.allowModeChange then Text.golosovaniePosleRaunda else Text.odinRezhimNaVse
|
||
explanation.Text = if showPlayers then Text.vyberiteIgrokovSEtogo
|
||
elseif isPrivate then Text.naServerePokaNet
|
||
elseif localPreview then Text.vLokalNomTeste
|
||
else Text.lyuboyIgrokSmozhetPodklyuchit
|
||
action.Text = if party then Text.otmenitPriglasheniya
|
||
elseif isPrivate then Text.otpravitPriglasheniya else Text.sozdatArenu2
|
||
refreshSelection()
|
||
end
|
||
|
||
for id, card in modeCards do
|
||
local input = assert(card.button)
|
||
input.Activated:Connect(function()
|
||
if sending or party then return end
|
||
roundOptions.initialMode = id
|
||
updatePanel()
|
||
end)
|
||
end
|
||
changeToggle.Activated:Connect(function()
|
||
if sending or party then return end
|
||
roundOptions.allowModeChange = not roundOptions.allowModeChange
|
||
updatePanel()
|
||
end)
|
||
|
||
local function setOpen(open: boolean)
|
||
if not open then
|
||
if arena and arena.mode then sending = false end
|
||
arena, arenaDetails, joinNote, preferredSide = nil, nil, nil, nil
|
||
for _, team in {blueTeam, orangeTeam} do team.hovered, team.focused = false, false end
|
||
resetTeamReveal()
|
||
end
|
||
shade.Visible = open
|
||
pg:SetAttribute("HunterArenaCreator", if open then true else nil)
|
||
if opening then opening:Cancel() end
|
||
if open then
|
||
panel.Visible, detailsPanel.Visible = not arena, arena ~= nil
|
||
if not arena then renderList(); updatePanel() end
|
||
local activePanel = if arena then detailsPanel else panel
|
||
activePanel.Position = UDim2.fromScale(.5, .53)
|
||
opening = TweenService:Create(activePanel, TweenInfo.new(.23, Enum.EasingStyle.Quart), {Position = UDim2.fromScale(.5, .5)})
|
||
opening:Play()
|
||
end
|
||
refreshLaunch()
|
||
end
|
||
|
||
launch.Activated:Connect(function()
|
||
if hosted then request("Exit") else setOpen(true) end
|
||
end)
|
||
close.Activated:Connect(function() setOpen(false) end)
|
||
detailsClose.Activated:Connect(function() setOpen(false) end)
|
||
public.Activated:Connect(function()
|
||
isPrivate, status.Text = false, ""
|
||
renderList()
|
||
updatePanel()
|
||
end)
|
||
private.Activated:Connect(function()
|
||
isPrivate, status.Text = true, ""
|
||
renderList()
|
||
updatePanel()
|
||
end)
|
||
action.Activated:Connect(function()
|
||
if party then
|
||
remote:FireServer("Cancel")
|
||
elseif isPrivate then
|
||
local ids = {}
|
||
for id in selected do table.insert(ids, id) end
|
||
request("InvitePrivate", ids, roundOptions)
|
||
else
|
||
request("CreatePublic", roundOptions)
|
||
end
|
||
end)
|
||
|
||
local function localTeams(mode: string): Details
|
||
local result: Details = {id = mode, players = 0, blue = {}, orange = {}}
|
||
for _, candidate in Players:GetPlayers() do
|
||
local side = candidate:GetAttribute("ArenaTeam")
|
||
if (side == "Blue" or side == "Orange") and Modes.of(candidate) == mode then
|
||
result.players += 1
|
||
table.insert(if side == "Blue" then result.blue else result.orange, {
|
||
userId = candidate.UserId, displayName = candidate.DisplayName,
|
||
})
|
||
end
|
||
end
|
||
return result
|
||
end
|
||
|
||
local function renderTeam(column: TeamColumn, members: {Hosting.Member})
|
||
local keys = {}
|
||
for index, member in members do keys[index] = tostring(member.userId) end
|
||
local stamp = table.concat(keys, ",")
|
||
if stamp == column.stamp then return end
|
||
column.stamp = stamp
|
||
column.count.Text = string.format("%d / %d", #members, Hosting.MaxPlayers // 2)
|
||
clearList(column.scroll)
|
||
if #members == 0 then
|
||
leftLabel(column.scroll, "Empty", Text.pokaNikogo, 8, 0, 249, 34, 14, UI.Muted)
|
||
return
|
||
end
|
||
for index, member in members do
|
||
local item = UI.element("PlayerRow", column.scroll, UDim2.new(), UDim2.new(1, -9, 0, 36))
|
||
item.Name = "Player_" .. member.userId
|
||
item.LayoutOrder = index
|
||
item.BackgroundColor3 = dark:Lerp(column.accent, .18)
|
||
UI.hoverRow(item, column.accent)
|
||
showAvatar(UI.portrait(item, UDim2.fromOffset(6, 4), 28, column.accent), member.userId, member.displayName)
|
||
leftLabel(item, "PlayerName", member.displayName, 41, 0, 207, 36, 14, UI.Ink)
|
||
end
|
||
end
|
||
|
||
local function redrawDetails(now: number)
|
||
local choice = arena
|
||
if not choice then return end
|
||
local localMode = choice.mode
|
||
local data = if localMode then localTeams(localMode) else arenaDetails
|
||
renderTeam(blueTeam, if data then data.blue else {})
|
||
renderTeam(orangeTeam, if data then data.orange else {})
|
||
local full = data ~= nil and data.players >= Hosting.MaxPlayers or player:GetAttribute("HostedArenaFull") == true
|
||
local isOpen = not localMode or Modes.open(roundState, localMode, now)
|
||
local ready = not sending and data ~= nil and not full and isOpen
|
||
local blueIssue = if data then Hosting.teamJoinError(#data.blue, #data.orange) else nil
|
||
local orangeIssue = if data then Hosting.teamJoinError(#data.orange, #data.blue) else nil
|
||
local issue = if preferredSide == "Blue" then blueIssue else orangeIssue
|
||
for side, team in teamColumns do
|
||
local teamIssue = if side == "Blue" then blueIssue else orangeIssue
|
||
team.hit.Interactable = ready and teamIssue == nil
|
||
if not team.hit.Interactable then team.pressed = false end
|
||
team.marker.Text = if confirmedSide == side then Text.vashaKomanda
|
||
elseif teamIssue == "Full" then Text.netMest elseif teamIssue == "Balance" then Text.balansKomand
|
||
elseif preferredSide == side then Text.vybrano else Text.vybrat
|
||
team.marker.TextColor3 = if teamIssue then UI.Muted else team.accent
|
||
showTeamFeedback(team, side)
|
||
end
|
||
connect.Interactable = ready and preferredSide ~= nil and issue == nil
|
||
detailsClose.Interactable = not sending
|
||
connect.Text = if confirmedSide then Text.vkhodNaArenu
|
||
elseif sending and localMode then Text.proveryaemKomandu
|
||
elseif preferredSide == "Blue" then Text.podklyuchitSyaZaSinikh
|
||
elseif preferredSide == "Orange" then Text.podklyuchitSyaZaOranzhevykh else Text.podklyuchitSya
|
||
local accent = if preferredSide == "Orange" then UI.Orange else UI.Blue
|
||
connect.BackgroundColor3 = if connect.Interactable then accent else dark:Lerp(UI.Muted, .18)
|
||
connect.TextColor3 = if connect.Interactable then dark else UI.Muted
|
||
detailsStatus.Text = joinNote or (if confirmedSide == "Blue" then Text.vyVKomandeSinikh
|
||
elseif confirmedSide == "Orange" then Text.vyVKomandeOranzhevykh
|
||
elseif sending then Text.podklyuchaemsya
|
||
elseif not data then Text.zagruzhaemSostavy elseif full then Text.arenaZapolnena
|
||
elseif not isOpen then Text.podklyuchenieOtkroetsyaSNachalom
|
||
elseif preferredSide and issue then Text.vybrannayaKomandaPokaNedostupna
|
||
elseif not preferredSide then Text.vyberiteKomandu else "")
|
||
end
|
||
|
||
for side, team in teamColumns do
|
||
local function feedback() showTeamFeedback(team, side) end
|
||
team.hit.MouseEnter:Connect(function()
|
||
team.hovered = true
|
||
feedback()
|
||
end)
|
||
team.hit.MouseLeave:Connect(function()
|
||
team.hovered, team.pressed = false, false
|
||
feedback()
|
||
end)
|
||
team.hit.SelectionGained:Connect(function()
|
||
team.focused = true
|
||
feedback()
|
||
end)
|
||
team.hit.SelectionLost:Connect(function()
|
||
team.focused, team.pressed = false, false
|
||
feedback()
|
||
end)
|
||
team.hit.InputBegan:Connect(function(input)
|
||
if team.hit.Interactable and (input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch
|
||
or input.KeyCode == Enum.KeyCode.ButtonA or input.KeyCode == Enum.KeyCode.Return) then
|
||
team.pressed = true
|
||
feedback()
|
||
end
|
||
end)
|
||
team.hit.InputEnded:Connect(function(input)
|
||
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch
|
||
or input.KeyCode == Enum.KeyCode.ButtonA or input.KeyCode == Enum.KeyCode.Return then
|
||
team.pressed = false
|
||
feedback()
|
||
end
|
||
end)
|
||
team.hit.Activated:Connect(function()
|
||
if not team.hit.Interactable or sending or not arena then return end
|
||
preferredSide, joinNote = side, nil
|
||
redrawDetails(workspace:GetServerTimeNow())
|
||
end)
|
||
-- The transparent selector covers the roster, so keep the wheel available there.
|
||
local function scrollTeam(delta: number)
|
||
local maximum = math.max(0, team.scroll.AbsoluteCanvasSize.Y - team.scroll.AbsoluteWindowSize.Y)
|
||
team.scroll.CanvasPosition = Vector2.new(0, math.clamp(team.scroll.CanvasPosition.Y + delta, 0, maximum))
|
||
end
|
||
team.hit.MouseWheelForward:Connect(function() scrollTeam(-42) end)
|
||
team.hit.MouseWheelBackward:Connect(function() scrollTeam(42) end)
|
||
end
|
||
|
||
local function fetchDirectory(more: boolean)
|
||
local now = workspace:GetServerTimeNow()
|
||
if hosted or localPreview or listingPending or now - lastListRequest < 1.2 then return end
|
||
listingPending, lastListRequest = true, now
|
||
remote:FireServer(if more then "MorePublic" else "PublicList")
|
||
end
|
||
|
||
local function openArena(choice: Choice)
|
||
arena, arenaDetails, joinNote, preferredSide = choice, nil, nil, nil
|
||
detailsTitle.Text = choice.name
|
||
setOpen(true)
|
||
local now = workspace:GetServerTimeNow()
|
||
if not choice.mode then
|
||
lastDetailRequest = now
|
||
remote:FireServer("PublicDetails", choice.id)
|
||
end
|
||
redrawDetails(now)
|
||
end
|
||
|
||
local directoryCards: {[string]: ArenaCard} = {}
|
||
|
||
local function localChoice(ownerOverride: Player?): Choice
|
||
local mode = Modes.Procedural
|
||
local ownerId = remote:GetAttribute("LocalPublicOwnerUserId")
|
||
local owner = ownerOverride or (if typeof(ownerId) == "number" then Players:GetPlayerByUserId(ownerId) else nil)
|
||
return {id = mode, name = if owner then owner.DisplayName else Text.dinamicheskayaArena,
|
||
mode = mode, hostId = if owner then owner.UserId else nil, players = localTeams(mode).players,
|
||
ruleset = Rules.get(Modes.state(roundState, mode):GetAttribute("Ruleset")).id}
|
||
end
|
||
|
||
local function createArenaCard(choice: Choice): ArenaCard
|
||
local visual = ModeCard.new(arenaList, choice.ruleset, UDim2.new(), UDim2.new(1, -13, 0, cardHeight), true)
|
||
local item = assert(visual.button)
|
||
item.Name = choice.id
|
||
visual.art.Size = UDim2.new(1, -12, 1, -58)
|
||
visual.title.Position = UDim2.new(0, 8, 1, -51)
|
||
visual.title.Size = UDim2.new(1, -16, 0, 27)
|
||
visual.badgePanel.Size = UDim2.fromOffset(65, 27)
|
||
visual.badge.TextSize = 14
|
||
local name = UI.label(item, "ArenaName", choice.name, UDim2.new(0, 10, 1, -25), UDim2.new(1, -20, 0, 20), 12, UI.Muted)
|
||
name.TextTruncate = Enum.TextTruncate.AtEnd
|
||
local hostId = choice.hostId
|
||
if hostId then
|
||
showAvatar(UI.portrait(item, UDim2.new(0, 12, 1, -25), 19, visual.accent), hostId, choice.name)
|
||
name.Position, name.Size = UDim2.new(0, 38, 1, -25), UDim2.new(1, -48, 0, 20)
|
||
name.TextXAlignment = Enum.TextXAlignment.Left
|
||
end
|
||
local entry = {choice = choice, visual = visual, name = name}
|
||
item.Activated:Connect(function() openArena(entry.choice) end)
|
||
return entry
|
||
end
|
||
|
||
local function renderDirectory()
|
||
local choices: {Choice} = {}
|
||
table.insert(choices, localChoice())
|
||
for _, entry in listings do
|
||
table.insert(choices, {id = entry.id, name = entry.hostName, hostId = entry.hostId, players = entry.players,
|
||
ruleset = Rules.get(entry.ruleset).id})
|
||
end
|
||
local visible: {[string]: boolean} = {}
|
||
for index, choice in choices do
|
||
visible[choice.id] = true
|
||
local entry = directoryCards[choice.id]
|
||
if not entry or entry.choice.ruleset ~= choice.ruleset or entry.choice.hostId ~= choice.hostId then
|
||
if entry then entry.visual.root:Destroy() end
|
||
entry = createArenaCard(choice)
|
||
directoryCards[choice.id] = entry
|
||
end
|
||
entry.choice = choice
|
||
entry.name.Text = choice.name
|
||
entry.visual.root.LayoutOrder = index
|
||
entry.visual.badge.Text = string.format("%d / %d", choice.players, Hosting.MaxPlayers)
|
||
end
|
||
for id, entry in directoryCards do
|
||
if not visible[id] then
|
||
entry.visual.root:Destroy()
|
||
directoryCards[id] = nil
|
||
end
|
||
end
|
||
moreArenas.LayoutOrder, moreArenas.Visible = #choices + 1, hasMore
|
||
local height = #choices * cardHeight + (#choices - 1) * rowGap
|
||
if hasMore then height += rowGap + moreHeight end
|
||
if height ~= contentHeight then
|
||
contentHeight = height
|
||
fit()
|
||
end
|
||
end
|
||
|
||
moreArenas.Activated:Connect(function() fetchDirectory(true) end)
|
||
refreshDirectory.Activated:Connect(function()
|
||
expandedList = false
|
||
fetchDirectory(false)
|
||
end)
|
||
connect.Activated:Connect(function()
|
||
local choice = arena
|
||
local side = preferredSide
|
||
if not choice or not side or not connect.Interactable then return end
|
||
joinNote = nil
|
||
if choice.mode then request("LocalJoin", choice.mode, side) else request("JoinPublic", choice.id, side) end
|
||
redrawDetails(workspace:GetServerTimeNow())
|
||
end)
|
||
|
||
local function showInvite()
|
||
local invite = currentInvite
|
||
invitation.Visible = invite ~= nil and not transferring
|
||
if not invite then return end
|
||
inviteTitle.Text = if accepted then Text.priglasheniePrinyato else Text.priglashenieNaArenu
|
||
accept.Visible = not accepted
|
||
decline.Text = if accepted then Text.otmenitU else Text.otklonitU
|
||
end
|
||
|
||
local function respond(agree: boolean)
|
||
local invite = currentInvite
|
||
if not invite or transferring or (agree and accepted) then return end
|
||
remote:FireServer("Answer", invite.id, agree)
|
||
end
|
||
accept.Activated:Connect(function() respond(true) end)
|
||
decline.Activated:Connect(function() respond(false) end)
|
||
local inputConnection = UserInputService.InputBegan:Connect(function(input, processed)
|
||
if processed or UserInputService:GetFocusedTextBox() or not invitation.Visible then return end
|
||
if input.KeyCode == Enum.KeyCode.Y then respond(true) end
|
||
if input.KeyCode == Enum.KeyCode.U then respond(false) end
|
||
end)
|
||
|
||
local messageConnection = remote.OnClientEvent:Connect(function(event: string, data: any)
|
||
if event == "Invite" then
|
||
local invite: Invite = data
|
||
currentInvite, accepted = invite, false
|
||
hostLabel.Text, hostAccount.Text = invite.hostName, Text.sozdatel .. invite.hostUsername
|
||
showAvatar(portrait, invite.hostId, invite.hostName)
|
||
showInvite()
|
||
elseif event == "Accepted" and currentInvite and currentInvite.id == data then
|
||
accepted = true
|
||
showInvite()
|
||
elseif event == "InviteClosed" and currentInvite and currentInvite.id == data then
|
||
currentInvite, accepted = nil, false
|
||
showInvite()
|
||
elseif event == "Party" then
|
||
party, sending = data, false
|
||
updatePanel()
|
||
elseif event == "PartyClosed" then
|
||
party, sending = nil, false
|
||
updatePanel()
|
||
status.Text = data or ""
|
||
if data and not shade.Visible then showNotice(data) end
|
||
elseif event == "PublicList" then
|
||
listingPending = false
|
||
hasMore, expandedList = data.more, data.append
|
||
if data.append then
|
||
local seen: {[string]: boolean} = {}
|
||
for _, row in listings do seen[row.id] = true end
|
||
for _, row in data.rows do if not seen[row.id] then table.insert(listings, row) end end
|
||
else
|
||
listings = data.rows
|
||
end
|
||
renderDirectory()
|
||
elseif event == "ListUnavailable" then
|
||
listingPending = false
|
||
if browser.Visible then showNotice(Text.spisokPublichnykhArenVremenno) end
|
||
elseif event == "PublicDetails" and arena and data.id == arena.id then
|
||
if not arenaDetails then joinNote = nil end
|
||
arenaDetails = data
|
||
redrawDetails(workspace:GetServerTimeNow())
|
||
elseif event == "DetailsUnavailable" and arena and data == arena.id then
|
||
arenaDetails = nil
|
||
joinNote = Text.arenaZakrylasIliSostavy
|
||
redrawDetails(workspace:GetServerTimeNow())
|
||
elseif event == "LocalPublicReady" then
|
||
sending = false
|
||
renderDirectory()
|
||
openArena(localChoice(player))
|
||
elseif event == "Transfer" then
|
||
sending, transferring = false, true
|
||
setOpen(false)
|
||
showInvite()
|
||
showNotice(data, true)
|
||
elseif event == "Error" then
|
||
sending, transferring = false, false
|
||
updatePanel()
|
||
refreshLaunch()
|
||
showInvite()
|
||
if arena then
|
||
joinNote = data
|
||
redrawDetails(workspace:GetServerTimeNow())
|
||
elseif shade.Visible then status.Text = data else showNotice(data) end
|
||
end
|
||
end)
|
||
|
||
local joinErrors: {[string]: string} = {
|
||
Full = Text.vVybrannoyKomandeNet,
|
||
Balance = Text.sostavyIzmenilisPodklyuchitesEschyo,
|
||
BetweenRounds = Text.dozhditesNachalaSleduyuschegoRaunda,
|
||
Spawning = Text.personazhEschyoZagruzhaetsyaPoprobuyte,
|
||
AwaitingAdmission = Text.proveryaemDostupKArene,
|
||
}
|
||
local joinConnection = join.OnClientEvent:Connect(function(result: string, side: Side?)
|
||
if not sending or not arena or not arena.mode then return end
|
||
if result == "TeamSelected" and (side == "Blue" or side == "Orange") then
|
||
revealTeam(side)
|
||
redrawDetails(workspace:GetServerTimeNow())
|
||
return
|
||
end
|
||
sending = false
|
||
if result == "Joined" or result == "AlreadyPlaying" then
|
||
setOpen(false)
|
||
else
|
||
resetTeamReveal()
|
||
joinNote = joinErrors[result] or Text.neUdalosPodklyuchitSya
|
||
redrawDetails(workspace:GetServerTimeNow())
|
||
end
|
||
end)
|
||
local launcherConnection = roundHud:GetAttributeChangedSignal("LobbyAvailable"):Connect(refreshLaunch)
|
||
local function refreshOwner()
|
||
local name = remote:GetAttribute("OwnerName")
|
||
ownerLabel.Text = if typeof(name) == "string" then Text.vladelets .. name else ""
|
||
end
|
||
local ownerConnection = remote:GetAttributeChangedSignal("OwnerName"):Connect(refreshOwner)
|
||
local votingConnection = pg:GetAttributeChangedSignal("HunterVoting"):Connect(function()
|
||
if pg:GetAttribute("HunterVoting") and shade.Visible then setOpen(false) end
|
||
end)
|
||
local teamConnection = player:GetAttributeChangedSignal("ArenaTeam"):Connect(function()
|
||
if player:GetAttribute("ArenaTeam") and shade.Visible then
|
||
if arena and arena.mode then sending = false end
|
||
setOpen(false)
|
||
end
|
||
end)
|
||
local function showFull()
|
||
if player:GetAttribute("HostedArenaFull") then showNotice(Text.arenaZapolnenaMozhnoVernut, true) end
|
||
end
|
||
local fullConnection = player:GetAttributeChangedSignal("HostedArenaFull"):Connect(showFull)
|
||
showFull()
|
||
local function showTeamNotice()
|
||
local issue = player:GetAttribute("HostedArenaTeamNotice")
|
||
if typeof(issue) == "string" then showNotice(joinErrors[issue] or Text.vybrannayaKomandaNedostupna) end
|
||
end
|
||
local arrivalTeamConnection = player:GetAttributeChangedSignal("HostedArenaTeamNotice"):Connect(showTeamNotice)
|
||
showTeamNotice()
|
||
local function playersChanged()
|
||
if shade.Visible and not arena and isPrivate then renderList(); updatePanel() end
|
||
end
|
||
local addedConnection = Players.PlayerAdded:Connect(playersChanged)
|
||
local removingConnection = Players.PlayerRemoving:Connect(function(other)
|
||
selected[other.UserId] = nil
|
||
task.defer(playersChanged)
|
||
end)
|
||
|
||
local clock = RunService.Heartbeat:Connect(function()
|
||
if not browser.Visible and not arena and not invitation.Visible and not party then return end
|
||
local now = workspace:GetServerTimeNow()
|
||
local second = math.floor(now * 2)
|
||
if second == clockSecond then return end
|
||
clockSecond = second
|
||
if browser.Visible then
|
||
renderDirectory()
|
||
if listingPending and now - lastListRequest > 4 then listingPending = false end
|
||
if not hosted and not localPreview and not expandedList and now - lastListRequest >= 12 then fetchDirectory(false) end
|
||
end
|
||
local choice = arena
|
||
if choice then
|
||
if not choice.mode and now - lastDetailRequest > (if arenaDetails then 7 else 2) then
|
||
lastDetailRequest = now
|
||
remote:FireServer("PublicDetails", choice.id)
|
||
end
|
||
redrawDetails(now)
|
||
end
|
||
local invite = currentInvite
|
||
if invite then
|
||
local left = math.max(0, math.ceil(invite.expires - now))
|
||
inviteTimer.Text = string.format("%02d", left)
|
||
if left == 0 then
|
||
currentInvite, accepted = nil, false
|
||
showInvite()
|
||
end
|
||
end
|
||
local pending = party
|
||
if pending then
|
||
local left = math.max(0, math.ceil(pending.expires - now))
|
||
status.Text = string.format(Text.prinyaliDZhdyomD, pending.accepted, pending.pending, left)
|
||
if not shade.Visible then showNotice(status.Text, true) end
|
||
end
|
||
end)
|
||
script.Destroying:Once(function()
|
||
for _, connection in {clock, inputConnection, messageConnection, joinConnection, launcherConnection, ownerConnection, votingConnection,
|
||
teamConnection, fullConnection, arrivalTeamConnection, addedConnection, removingConnection} do
|
||
connection:Disconnect()
|
||
end
|
||
if opening then opening:Cancel() end
|
||
resetTeamReveal()
|
||
pg:SetAttribute("HunterArenaCreator", nil)
|
||
gui:Destroy()
|
||
end)
|
||
updatePanel()
|
||
refreshLaunch()
|
||
refreshOwner()
|
||
renderDirectory()
|