PlayerIO

The fastest way to build online games without breaking a sweat.

HTML5 (Javascript) Client Reference

javascript (html5) oneScore class informationClass oneScore

Language: Javascript (HTML5)

The OneScore service. This class is used to update the score of the current user, and loading the scores of other users.

Example

Load the current user's OneScore and print the details:

Example

Setting the current user's OneScore:

Example

Adding to the current user's OneScore:

Example

Loading other users' OneScore:

Properties

 
percentile :Number

The percentile compared to all other players. A value from 0 -> 100. A value of 30.0 means you are in the bottom 30% of players. A value of 100 means you are in the top 1% with other players. You must call refresh() first to initialize this value.

score :Number

The score. You must call refresh() first to initialize this value.

topRank :Number

The absolute ranking number -- if you are one of the N top players, then it returns N. 1 means you are the best. Returns 0 if you are not one the top N players. (N is currently 1000.) You must call refresh() first to initialize this value.

Methods

 
add (score, successCallback, errorCallback):

Adds the score to the OneScore for the user.

load (userIds, successCallback, errorCallback):

Load the OneScores for multiple users by their connectUserId

refresh (successCallback, errorCallback):

Refresh the OneScore of the current user.

set (score, successCallback, errorCallback):

Sets the OneScore for the user.

oneScore.percentile

percentile :Number

The percentile compared to all other players. A value from 0 -> 100. A value of 30.0 means you are in the bottom 30% of players. A value of 100 means you are in the top 1% with other players. You must call refresh() first to initialize this value.

oneScore.score

score :Number

The score. You must call refresh() first to initialize this value.

oneScore.topRank

topRank :Number

The absolute ranking number -- if you are one of the N top players, then it returns N. 1 means you are the best. Returns 0 if you are not one the top N players. (N is currently 1000.) You must call refresh() first to initialize this value.

oneScore.add

add (score, successCallback, errorCallback):

Adds the score to the OneScore for the user.

Arguments

score:number
The score to add for the user.
successCallback:function(oneScoreValue)
Callback function that will be called when the operation has been completed.
errorCallback:function(PlayerIOError)
Callback function that will be called if an error occurs.

oneScore.load

load (userIds, successCallback, errorCallback):

Load the OneScores for multiple users by their connectUserId

Arguments

userIds:string[]
The list of users to load scores for.
successCallback:function(oneScoreValue[])
Callback function that will be called with the loaded scores.
errorCallback:function(PlayerIOError)
Callback function that will be called if an error occurs.

oneScore.refresh

refresh (successCallback, errorCallback):

Refresh the OneScore of the current user.

Arguments

successCallback:function()
Callback function that will be called when the refresh is complete
errorCallback:function(PlayerIOError)
Callback function that will be called if an error occurs

oneScore.set

set (score, successCallback, errorCallback):

Sets the OneScore for the user.

Arguments

score:number
The score to set for the user.
successCallback:function(oneScoreValue)
Callback function that will be called when the operation has been completed.
errorCallback:function(PlayerIOError)
Callback function that will be called if an error occurs.