MatchmakingService

Mostrar obsoleto

*Este contenido se traduce usando la IA (Beta) y puede contener errores. Para ver esta página en inglés, haz clic en aquí.

No creable
Servicio
No replicado

MatchmakingService es responsable de gestionar los atributos de emparejamiento personalizados. Úselo para leer y escribir datos de emparejamiento.

Resumen

Métodos

Propiedades

Métodos

GetServerAttribute

Recupera el valor de un atributo específico del servidor.

Parámetros

name: string

El nombre del atributo del servidor. Limitado a un máximo de 50 caracteres.

Valor predeterminado: ""

Devuelve

Devuelve el valor del atributo del servidor si el atributo se encuentra y si el error es nil .De lo contrario, devuelve nil para el valor del atributo y un mensaje de error.

InitializeServerAttributesForStudio

Inicia el esquema de atributos del servidor y sus valores para probar en Studio. Este método es opcional y no tiene efecto cuando se ejecuta fuera de Studio.

Parámetros

serverAttributes: Dictionary

Un array de pares de nombre-valor de atributo.

Valor predeterminado: ""

Devuelve

Devuelve true si la llamada tuvo éxito. De lo contrario, devuelve false y un mensaje de error.

SetServerAttribute

Asigna un valor a un atributo específico del servidor.

Parámetros

name: string

El nombre del atributo del servidor. Limitado a un máximo de 50 caracteres.

Valor predeterminado: ""
value: Variant

El valor del atributo del servidor. Limitado a un máximo de 50 caracteres.

Valor predeterminado: ""

Devuelve

Devuelve true si la llamada tuvo éxito. De lo contrario, devuelve false y un mensaje de error.

Muestras de código

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

Eventos