Rex's plugins for Construct2
  • Home
  • Map
  • Tutorial/Templates
  • News
  • About

rex_firebase_leaderboard

Plugin, ACE table, Discussion thread
Dependence:
rex_firebase_apiV3

Introduction
Leader board built on firebase.

Usage
Sample capx (auto update) , sample capx v3
Sample capx (manual update), sample capx v3


Post score
Call "
Action:Post score" to post score. It will save the score and other information indexed by UserID, which might got after
authentication.
"Condition:On post complete" will be triggered if posting successfully, otherwise "Condition:On post error" will be triggered. Get posted player name by "Expression:PostPlayerName" under "Condition:On post complete" condition.

Post score if greater/if less
Sample capx
Call "
Action:Post score" and set "
Post condition" to "if greater", "if less" to post the score only when the new score is greater/less then saved score.
Post score if not existed
Call "Action:Post score" and set "Post condition" to "if not existed" to post the score only when the score dose not exist. i.e. posting default score.
Add to score
Sample capx
Call "Action:Add to score" to add a value to current score.
Order
Set "
Order" to "Large to small" or "Small to large" in properties table, to order these score of players.
It will sort by name if the score are the same.

Update scores
There are two modes to update score of players - auto update , and manual update. Which is set in "
Update" in properties table.
Manual update
Set "
Update" to "Manual" in properties table. Then call "Action:Update top" or "Action:Update all" to fetch score of players from firebase server. Each action will request a data fetching.
"Condition:On update" will be triggered when received data, then use "
Condition:For each rank", or "Condition:For each rank in a range" to retrieval score of each fetched player. During this condition, get information by these expressions-
  • Expression:CurPlayerRank , which is 0-based
  • Expression:CurPlayerName
  • Expression:CurPlayerScore
  • Expression:CurExtraData
  • Expression:CurUserID
Or get these information by rank index with these expressions-
  • Expression:Rank2PlayerName
  • Expression:Rank2PlayerScore
  • Expression:Rank2ExtraData
The rank index could be got by UserID with "Expression:UserID2Rank". It is useful to get the rank of current player.
My UserID -> "Expression:UserID2Rank" -> My rank
"Expression:UserID2Rank" will return (-1) if the UserID does not exist in fetched data.
Usually,
"Expression:UserID2Rank" is used under
"Action:Update all" to get the rank of current player.

Auto update
Set "Update" to "
Auto" in properties table. Then call "Action:Update top" or "Action:Update all" to notify firebase server to update scores if they had been changed. This action only needs to be used once.
"Condition:On update" will be triggered when firebase notifying.
"
Action:Stop updating" could be used to stop auto updating.
Other things are the same as "Manual update" in previous section.
This mode is used to
update leadboard real-time, since each score changed would trigger "Condition:On update" of each client.

Compare with rex_parse_leaderboard plugin
This plugin and
rex_parse_leaderboard plugin both support leader board.
This plugin
is good at showing top N ranks in real-time, but this plugin could not show ranks in pages. It reads all data or top N back.


Create a free web site with Weebly
  • Home
  • Map
  • Tutorial/Templates
  • News
  • About