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 = "Advanced",
Elo = 123.456,
TrainingMode = true
})
end
-- ดึงคุณสมบัติ Level
local currentLevel, errorMessage = MatchmakingService:GetServerAttribute("Level")
if errorMessage then
warn(errorMessage)
else
print("ระดับปัจจุบัน: " .. currentLevel)
end
-- อัปเดตค่าคุณสมบัติ Level เป็น Advanced
local success, errorMessage = MatchmakingService:SetServerAttribute("Level", "Advanced")
if not success then
warn("ไม่สามารถอัปเดตคุณสมบัติเซิร์ฟเวอร์ [Level] เป็น [Advanced] ได้เนื่องจากข้อผิดพลาด: " .. errorMessage)
else
print("ตั้งค่า [Level] เป็น [Advanced] สำเร็จ")
end