Skip to main content

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

yes you can but im not quite sure if the ranking will be correct but try the Extra field you can use Strings there and convert them as your liking to either int or floats

to the ranking I think that I found a solution for that in the leaderboard you can activate an option called ascending order im not quite sure if this would fix it but you can try

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using UnityEngine.Events;

using UnityEngine.UI;

using TMPro;

using Dan.Main;

using System.Runtime.CompilerServices;

using JetBrains.Annotations;

public class Leaderboard : MonoBehaviour

{

    [SerializeField] PlayerMovement playermovement_script;

    [SerializeField] private List<TextMeshProUGUI> names;

    [SerializeField] private List<TextMeshProUGUI> scores;

    private string[] badWords = new string[] { "Hurensohn", "Wixer"};

    private string publicLeaderboardKey = "89ba609eb052086681e456ec870985cb8f14a460da720298cded4a337e9ded2b";

    //Scoremanager

    [SerializeField] private TextMeshProUGUI inputScore;

    [SerializeField] private TMP_InputField inputName;

    public UnityEvent<string, int> submitScoreEvent;

    private void Start()

    {

        GetLeaderboard();

    }

    public void GetLeaderboard()

    {

        LeaderboardCreator.GetLeaderboard(publicLeaderboardKey, ((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 SetLeaderboardEntry(string username, int score)

    {

        LeaderboardCreator.UploadNewEntry(publicLeaderboardKey, username, score, ((msg) =>

        {

            if (System.Array.IndexOf(badWords, name) != -1) return;

            GetLeaderboard();

        }));

    }

    public void SubmitScore()

    {

        submitScoreEvent.Invoke(inputName.text, System.Convert.ToInt32(timer_script.lastScore));

    }

}

Thats my current script. I am very confused with the extra data. Can you help me with it?

I see your german? Wenn ja dann hier auf deutsch, was bei mir hier die lösung war das z.B. bei LeaderboardCreator.UploadNewEntry(... dort kannst du nach score eine klammer und dann damit du dieses Extra feld benutzen du kannst also: ..., score, extra, ((msg)... nutzen und damit das auch richtig funktioniert musst du bei der Method in der klammer noch "extra" als string deklarieren und je nachdem wo du es referenced auch noch einen string für hinzufügen, sry wenn du es nicht verstehen solltes

Danke, das habe ich soweit verstanden. Aber mir ging es vorallem um die Methode von SubmitScore().

    public void SubmitScore()

    {

        submitScoreEvent.Invoke(inputName.text, System.Convert.ToInt32(timer_script.lastScore));

    }


Die Methode sumbmtiScoreEvent.Invoke nimmt nur 2 Argumente (ein String für den Namen und ein Integer für den score)