Kelas Engine
MatchmakingService
*Konten ini diterjemahkan menggunakan AI (Beta) dan mungkin mengandung kesalahan. Untuk melihat halaman ini dalam bahasa Inggris, klik di sini.
Rangkuman
Metode
GetServerAttribute(name: string):Tuple |
InitializeServerAttributesForStudio(serverAttributes: Dictionary):Tuple |
SetServerAttribute(name: string,value: Variant):Tuple |
Referensi API
Metode
GetServerAttribute
InitializeServerAttributesForStudio
Parameter
Memberikan nilai
SetServerAttribute
Parameter
value:Variant |
Memberikan nilai
Contoh Kode
Contoh Layanan Penjodohan
local MatchmakingService = game:GetService("MatchmakingService")
local RunService = game:GetService("RunService")
if RunService:IsStudio() then
-- Menyiapkan atribut awal dan skema untuk pengujian
MatchmakingService:InitializeServerAttributesForStudio({
Level = "Lanjutan",
Elo = 123.456,
TrainingMode = true
})
end
-- Mengambil atribut Level
local currentLevel, errorMessage = MatchmakingService:GetServerAttribute("Level")
if errorMessage then
warn(errorMessage)
else
print("Level saat ini: " .. currentLevel)
end
-- Memperbarui nilai atribut Level menjadi Lanjutan
local success, errorMessage = MatchmakingService:SetServerAttribute("Level", "Lanjutan")
if not success then
warn("Gagal memperbarui atribut server [Level] menjadi [Lanjutan] karena error: " .. errorMessage)
else
print("Berhasil mengatur [Level] ke [Lanjutan]")
end