MatchmakingService
*Questo contenuto è tradotto usando AI (Beta) e potrebbe contenere errori. Per visualizzare questa pagina in inglese, clicca qui.
MatchmakingService è responsabile della gestione degli attributi di matchmaking personalizzati. Usalo per leggere e scrivere dati di matchmaking.
Sommario
Proprietà
Metodi
Recupera il valore di un attributo server specifico.
Inizia lo schema dell'attributo del server e i suoi valori da testare in Studio.
Assegna un valore a un attributo server specifico.
Proprietà
Metodi
GetServerAttribute
Recupera il valore di un attributo server specifico.
Parametri
Il nome dell'attributo del server. Limitato a un massimo di 50 caratteri.
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
Un array di coppie nome-valore di attributo.
Restituzioni
Restituisce true se la chiamata è riuscita. Altrimenti, restituisce false e un Messaggiodi errore.
SetServerAttribute
Assegna un valore a un attributo server specifico.
Parametri
Il nome dell'attributo del server. Limitato a un massimo di 50 caratteri.
Il valore dell'attributo server. Limitato a un massimo di 50 caratteri.
Restituzioni
Restituisce true se la chiamata è riuscita. Altrimenti, restituisce false e un Messaggiodi errore.
Campioni di codice
The following code sample:
- Tests the hard-coded Level, Elo, and TrainingMode attributes in Studio with InitializeServerAttributesForStudio.
- Gets the Level attribute with GetServerAttribute.
- Updates the player's Level attribute with SetServerAttribute.
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