MatchmakingService 는 사용자 지정 매치메이킹 특성을 관리하는 책임이 있습니다. 매치메이킹 데이터를 읽고 쓰는 데 사용하십시오.
요약
메서드
특정 서버 특성의 값을 검색합니다.
Studio에서 테스트할 서버 특성 스키마와 해당 값을 시작합니다.
특정 서버 특성에 값을 할당합니다.
속성
메서드
GetServerAttribute
특정 서버 특성의 값을 검색합니다.
매개 변수
서버 특성의 이름. 최대 50자까지 제한됩니다.
반환
특성이 발견되고 오류가 nil인 경우 서버 특성 값을 반환합니다.그렇지 않으면 특성 값에 대해 nil를 반환하고 오류 메시지를 표시합니다.
InitializeServerAttributesForStudio
Studio에서 테스트할 서버 특성 스키마와 해당 값을 시작합니다. 이 방법은 선택적이며 Studio 외부에서 실행할 때 효과가 없습니다.
매개 변수
특성 이름-값 쌍 배열.
반환
호출이 성공하면 true 를 반환하고, 그렇지 않으면 false 와 오류 메시지를 반환합니다.
SetServerAttribute
특정 서버 특성에 값을 할당합니다.
매개 변수
서버 특성의 이름. 최대 50자까지 제한됩니다.
value: Variant
서버 특성의 값. 최대 50자로 제한됩니다.
반환
호출이 성공하면 true 를 반환하고, 그렇지 않으면 false 와 오류 메시지를 반환합니다.
코드 샘플
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.
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