概要
方法
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("由于错误: " .. errorMessage .. ",未能将服务器属性 [Level] 更新为 [高级]")
else
print("成功将 [Level] 设置为 [高级]")
end