Kit leaderboards module.

Handles client requests only on game servers.

Constructor

Methods

add (boardID:String, entityID:Int, points:Float, ?customInfo:String, ?boardKey:String):Void

Adds a record to the registered leaderboard. If the record with this entity ID exists, it will be overwritten. If the custom info argument is set and the board allows it, will also store custom info for the record for future use.

Parameters:

boardID

Leaderboard ID. Will throw an exception if this leaderboard does not exist.

entityID

Leaderboard record ID. Should be user ID in case of user leaderboard, for example.

points

New points value.

customInfo

(optional) Custom record info string. Max 1024 bytes long.

boardKey

(optional) Leaderboard storage key. Needed for API calls to leaderboards with rotations to handle transactions.

getBoardKey (boardID:String):String

Returns a current storage key for a given leaderboard ID. This is mainly needed to make transactions for rotational leaderboards.

Parameters:

boardID

Leaderboard ID.

Returns:

Leaderboard storage key.

getCall (c:ClientInfo, params:Params):Dynamic

kit/leaderboard.get

Returns a chunk of a given leaderboard with both custom and common record infos included.

Input:

  • boardID - String. Leaderboard ID.
  • minPlace - Int. Minimum place. Default is 1.
  • limit - Int. Amount of records to pull starting from minimum place. Default and maximum is 100.
  • getSelf - Bool. If true, will also get leaderboard record for this user.
  • getPrev - Bool. If true, will get a chunk from previous period. Only applicable to leaderboards with rotation. If it's the starting period, will return an empty list.

Output:

  • errorCode - String. Operation error code.
  • boardID - String. Leaderboard ID.
  • list - Array<{ id: Int, place: Int, score: Float, info: String, customInfo: String }>. Leaderboard contents. info and customInfo can be null.
  • self - Leaderboard record for this user in the same format as list record. If there is no such record or getSelf is false, self is set to null.
  • timeLeft - Seconds left until the next leaderboard rotation. Equals 0 if this leaderboard is not rotated or previous period is used.
  • period - Period number starting from 0.
  • minPlace - Int. Received value.
  • getSelf - Bool. Received flag value.
  • getPrev - Bool. Received flag value.

Error codes:

  • ok - Operation successful.
  • noSuchBoard - Board with this ID is not registered.

getPlace (boardID:String, entityID:Int):Int

Returns a place that this entity ID holds in this leaderboard.

Parameters:

boardID

Leaderboard ID. Will throw an exception if this leaderboard does not exist.

entityID

Leaderboard record ID. Should be user ID in case of user leaderboard, for example.

Returns:

Place in the leaderboard starting from 1. Returns 0 if there is no such record.

getScore (boardID:String, entityID:Int, ?boardKey:String):Float

Returns a score that this entity ID holds in this leaderboard.

Parameters:

boardID

Leaderboard ID. Will throw an exception if this leaderboard does not exist.

entityID

Leaderboard record ID. Should be user ID in case of user leaderboard, for example.

boardKey

(optional) Leaderboard storage key. Needed for API calls to leaderboards with rotations to handle transactions.

Returns:

Score in the leaderboard. Returns 0 if there is no such record.

remove (boardID:String, entityID:Int):Void

Removes a leaderboard record with this entity ID. In case of leaderboards with rotation it will only remove the record from the current one.

Parameters:

boardID

Leaderboard ID. Will throw an exception if this leaderboard does not exist.

entityID

Leaderboard record ID. Should be user ID in case of user leaderboard, for example.

updateInfoUser (entityID:Int, infostr:String):Bool

Updates user info string for user leaderboards.

Parameters:

entityID

User ID.

infostr

Info string. Max length 1024 bytes.

Returns:

True in case of success. False otherwise.