Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(+1)

I'm just wondering why when I enter a new entry it will replace the previous entry . so always there is only one entry even if I submit several values in editor 

my code 


using System.Collections.Generic;

using UnityEngine;

using TMPro;

using Dan.Main;

public class leaderboardd : MonoBehaviour

{

    // Start is called before the first frame update

    [SerializeField]

    private List<TextMeshProUGUI> Names;

    [SerializeField]

    private List<TextMeshProUGUI> Scores;

    private string publicleaderboaedkey = "64284967363c3ef000a80af46de3aba968e5ebfcdcc6406c57cdb0af2b4b5944";

    private void Start()

    {

        GetLeaderboard();

    }

    public void GetLeaderboard()

    {

        LeaderboardCreator.GetLeaderboard(publicleaderboaedkey, ((msg) => {

            int looplength = (msg.Length < Names.Count) ? msg.Length : Names.Count;

        for(int i =0; i< looplength; ++i)

        {

            Names[i].text = msg[i].Username;

            Scores[i].text = msg[i].Score.ToString();

            }

        }));

    }

    public void SetLeaderboard(string username,int score)

    {

        LeaderboardCreator.UploadNewEntry(publicleaderboaedkey, username,score,((msg) => {

            GetLeaderboard();

        }));

    }

}

Hello!

If you had not noticed, the FAQ contains an answer to your question:

There may only be one entry per one player. This is done to support features like name editing and deleting an entry in a safe way, such that other people don't mess around with other people's entries. If you do not want this, then disable "Unique Usernames" for your leaderboard and make use of the LeaderboardCreator.ResetPlayer() function during the callback from uploading an entry. Note that after this, a player's previous entry cannot be edited nor deleted by the player themself.

(1 edit) (+1)

I've created a hack: combining unique usernames with random hashes guarantees unique names, even if the base name is taken. For example, I send "Mike%123456" from one device and "Mike%234958" from another. In my game I can extract the nickname by splitting the string, and display "Mike" part only.