MatchmakingService

Visualizza obsoleti

*Questo contenuto è tradotto usando AI (Beta) e potrebbe contenere errori. Per visualizzare questa pagina in inglese, clicca qui.

Non costruibile
Assistenza
Non Replicato

MatchmakingService è responsabile della gestione degli attributi di matchmaking personalizzati. Usalo per leggere e scrivere dati di matchmaking.

Proprietà

Metodi

GetServerAttribute

Recupera il valore di un attributo server specifico.

Parametri

name: string

Il nome dell'attributo del server. Limitato a un massimo di 50 caratteri.

Valore predefinito: ""

Restituzioni

Restituisce il valore dell'attributo del server se l'attributo viene trovato e se l'errore è nil .Altrimenti, restituisce nil per il valore dell'attributo e un Messaggiodi errore.

InitializeServerAttributesForStudio

Inizia lo schema di attributi del server e i suoi valori per testare in Studio. Questo metodo è opzionale e non ha alcun effetto quando viene eseguito al di fuori di Studio.

Parametri

serverAttributes: Dictionary

Un array di coppie nome-valore di attributo.

Valore predefinito: ""

Restituzioni

Restituisce true se la chiamata è riuscita. Altrimenti, restituisce false e un Messaggiodi errore.

SetServerAttribute

Assegna un valore a un attributo server specifico.

Parametri

name: string

Il nome dell'attributo del server. Limitato a un massimo di 50 caratteri.

Valore predefinito: ""
value: Variant

Il valore dell'attributo server. Limitato a un massimo di 50 caratteri.

Valore predefinito: ""

Restituzioni

Restituisce true se la chiamata è riuscita. Altrimenti, restituisce false e un Messaggiodi errore.

Campioni di codice

The following code sample:

MarketplaceService sample

local MatchmakingService = game::GetService("MatchmakingService")
local RunService = game:GetService("RunService")
if RunService:IsStudio() then
-- Sets up initial attributes and schema for testing
MatchmakingService:InitializeServerAttributesForStudio(
{
Level = "Advanced",
Elo = 123.456,
TrainingMode = true
})
end
-- Retrieves the Level attribute
local currentLevel, error = MatchmakingService:GetServerAttribute("Level")
if error then
print(error)
else
print("Current level: " .. currentLevel)
end
-- Updates the Level attribute value to Advanced
local success, error = MatchmakingService:SetServerAttribute("Level", "Advanced")
if not success then
print("Failed to update server attribute [Level] to [Advanced] due to error: " .. error)
else
print("Successfully set [Level] to [Advanced]")
end

Eventi