Engine Class
MatchmakingService
*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่
สรุป
วิธีการ
GetServerAttribute(name: string):Tuple |
InitializeServerAttributesForStudio(serverAttributes: Dictionary):Tuple |
SetServerAttribute(name: string,value: Variant):Tuple |
เอกสารอ้างอิงเกี่ยวกับ API
วิธีการ
GetServerAttribute
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