리더보드
게임 페이지에 상위 플레이어의 결과와 로그인한 사용자의 순위 내 위치를 보여주는 맞춤형 리더보드를 표시할 수 있습니다.
아래 요청이 작동하려면 다음 사항을 확인하세요.
- SDK를 활성화 및 구성했으며 해당 개체를
ysdk
변수를 통해 사용할 수 있어야 합니다. - 개발자 대시보드에서 리더보드를 생성했습니다.
알림
개발자 대시보드의 기술 리더보드 이름 필드에 해당 이름이 있는 리더보드가 없는 경우 요청은 404 오류를 반환합니다.
리더보드 설명
이름별로 리더보드에 대한 설명을 가져오려면 ysdk.leaderboards.get_description()
을 사용합니다:
ysdk.leaderboards.get_description(
leaderboard_name: string,
callback: function
)
callback: function
— 호출된 메서드의 핸들러입니다. 형태는 다음과 같습니다:
function(self, description: table|nil): nil
description: table
— 리더보드에 대한 설명입니다. 다음과 같은 속성을 포함합니다:
description: {
app_id: string,
dеfault: boolean,
invert_sort_order: boolean,
decimal_offset: integer,
type: string,
name: string,
title: {
en: string,
ru: string
}
}
예시
function display_leaderboard()
ysdk.leaderboards.get_description("highscores",
function (self, description)
if description then
print(
description.name,
description.title.en
)
end
end)
end
새 점수
알림
인증된 사용자만이 요청할 수 있습니다. 필요한 경우 인증을 사용하십시오.
플레이어의 점수를 새로 설정하려면 ysdk.leaderboards.set_score()
를 사용합니다::
ysdk.leaderboards.set_score(
leaderboard_name: string,
score: integer,
extraData: string|nil
)
참고
요청은 초당 한 번 이상 전송할 수 없습니다. 그렇지 않으면 오류와 함께 요청이 거부됩니다.
순위 가져오기
알림
인증된 사용자만 요청이 가능합니다. 필요한 경우 인증을 하십시오.
사용자의 순위를 가져오려면 ysdk.leaderboards.get_player_entry()
를 사용합니다:
ysdk.leaderboards.get_player_entry(
leaderboard_name: string,
callback: function
)
callback: function
— 호출된 메서드의 핸들러. 형태는 다음과 같습니다:
function(self, player_entry: table|nil): nil
player_entry: table
— 사용자 순위입니다. 다음과 같은 속성을 포함합니다:
player_entry: {
score: integer,
extraData: string,
rank: integer,
avatar_src: {
small: string,
medium: string,
large: string,
},
avatar_srcset: {
small: string,
medium: string,
large: string,
},
lang: string,
public_name: string,
unique_id: string,
formatted_score: string
}
예시
function display_high_score()
ysdk.leaderboards.get_player_entry("highscores",
function (self, player_entry)
if player_entry then
print("highscore: " .. player_entry.score)
end
end)
end
리더보드 항목
사용자 순위를 표시하려면 ysdk.leaderboards.get_entries()
를 사용합니다:
ysdk.leaderboards.get_entries(
leaderboardName: string,
callback: function,
options: {
include_user: boolean|nil,
quantity_around: number|nil,
quantity_top: number|nil
}
)
callback: function
— 호출된 메서드의 핸들러입니다. 형태는 다음과 같습니다:
function(self, entries: table|nil): nil
entries: table
— 사용자 평점입니다. 속성은 다음과 같습니다:
entries: {
leaderboard: {
...
},
ranges: [
{
start: integer,
size: integer
}
],
userRank: integer,
entries: [
{
score: integer,
extraData: string,
rank: integer,
avatar_src: {
small: string,
medium: string,
large: string,
},
avatar_srcset: {
small: string,
medium: string,
large: string,
},
lang: string,
public_name: string,
unique_id: string,
formatted_score: string
},
...
]
}
Copied
Was the article helpful?
Previous
Next