Matchmaking Service
*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่
ข้อมูลสรุป
วิธีการ
GetServerAttribute(name: string):Tuple |
InitializeServerAttributesForStudio(serverAttributes: Dictionary):Tuple |
SetServerAttribute(name: string,value: Variant):Tuple |
เอกสารอ้างอิงเกี่ยวกับ API
วิธีการ
Get Server Attribute
Initialize Server Attributes For Studio
พารามิเตอร์
ส่งค่ากลับ
Set Server Attribute
พารามิเตอร์
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, setErrorMessage = MatchmakingService:SetServerAttribute("Level", "ขั้นสูง")
if not success then
warn("ไม่สามารถอัปเดตคุณสมบัติเซิร์ฟเวอร์ [Level] เป็น [ขั้นสูง] ได้เนื่องจากข้อผิดพลาด: " .. setErrorMessage)
else
print("ตั้งค่า [Level] เป็น [ขั้นสูง] สำเร็จ")
end