Klasa silnika
MatchmakingService
*Ta zawartość została przetłumaczona przy użyciu narzędzi AI (w wersji beta) i może zawierać błędy. Aby wyświetlić tę stronę w języku angielskim, kliknij tutaj.
Podsumowanie
Metody
GetServerAttribute(name: string):Tuple |
InitializeServerAttributesForStudio(serverAttributes: Dictionary):Tuple |
SetServerAttribute(name: string,value: Variant):Tuple |
Materiały referencyjne dotyczące interfejsów API
Metody
GetServerAttribute
InitializeServerAttributesForStudio
Parametry
Zwroty
SetServerAttribute
Parametry
value:Variant |
Zwroty
Przykłady kodu
Przykład usługi dopasowywania
local MatchmakingService = game:GetService("MatchmakingService")
local RunService = game:GetService("RunService")
if RunService:IsStudio() then
-- Konfiguruje początkowe atrybuty i schemat do testowania
MatchmakingService:InitializeServerAttributesForStudio({
Level = "Zaawansowany",
Elo = 123.456,
TrainingMode = true
})
end
-- Pobiera atrybut Level
local currentLevel, errorMessage = MatchmakingService:GetServerAttribute("Level")
if errorMessage then
warn(errorMessage)
else
print("Aktualny poziom: " .. currentLevel)
end
-- Aktualizuje wartość atrybutu Level na Zaawansowany
local success, errorMessage = MatchmakingService:SetServerAttribute("Level", "Zaawansowany")
if not success then
warn("Nie udało się zaktualizować atrybutu serwera [Level] na [Zaawansowany] z powodu błędu: " .. errorMessage)
else
print("Pomyślnie ustawiono [Level] na [Zaawansowany]")
end