概要
方法
GetServerAttribute(name: string):Tuple |
InitializeServerAttributesForStudio(serverAttributes: Dictionary):Tuple |
SetServerAttribute(name: string,value: Variant):Tuple |
API 參考
方法
InitializeServerAttributesForStudio
參數
返回
SetServerAttribute
參數
value:Variant |
返回
範例程式碼
配對服務範例
local MatchmakingService = game:GetService("MatchmakingService")
local RunService = game:GetService("RunService")
if RunService:IsStudio() then
-- 設置測試的初始屬性和架構
MatchmakingService:InitializeServerAttributesForStudio({
Level = "進階",
Elo = 123.456,
TrainingMode = true
})
end
-- 獲取 Level 屬性
local currentLevel, errorMessage = MatchmakingService:GetServerAttribute("Level")
if errorMessage then
warn(errorMessage)
else
print("當前等級: " .. currentLevel)
end
-- 將 Level 屬性值更新為進階
local success, errorMessage = MatchmakingService:SetServerAttribute("Level", "進階")
if not success then
warn("更新伺服器屬性 [Level] 為 [進階] 失敗,錯誤: " .. errorMessage)
else
print("成功將 [Level] 設定為 [進階]")
end