Lớp công cụ
MatchmakingService
*Nội dung này được dịch bằng AI (Beta) và có thể có lỗi. Để xem trang này bằng tiếng Anh, hãy nhấp vào đây.
Tóm Tắt
Phương Pháp
GetServerAttribute(name: string):Tuple |
InitializeServerAttributesForStudio(serverAttributes: Dictionary):Tuple |
SetServerAttribute(name: string,value: Variant):Tuple |
Tài Liệu Tham Khảo API
Phương Pháp
GetServerAttribute
InitializeServerAttributesForStudio
Tham Số
Lợi Nhuận
SetServerAttribute
Tham Số
value:Variant |
Lợi Nhuận
Mẫu mã
Mẫu dịch vụ ghép trận
local MatchmakingService = game:GetService("MatchmakingService")
local RunService = game:GetService("RunService")
if RunService:IsStudio() then
-- Thiết lập các thuộc tính ban đầu và lược đồ cho việc thử nghiệm
MatchmakingService:InitializeServerAttributesForStudio({
Level = "Nâng cao",
Elo = 123.456,
TrainingMode = true
})
end
-- Lấy thuộc tính Level
local currentLevel, errorMessage = MatchmakingService:GetServerAttribute("Level")
if errorMessage then
warn(errorMessage)
else
print("Mức độ hiện tại: " .. currentLevel)
end
-- Cập nhật giá trị thuộc tính Level thành Nâng cao
local success, errorMessage = MatchmakingService:SetServerAttribute("Level", "Nâng cao")
if not success then
warn("Không thể cập nhật thuộc tính máy chủ [Level] thành [Nâng cao] do lỗi: " .. errorMessage)
else
print("Đã thiết lập thành công [Level] thành [Nâng cao]")
end