I store a key/value pair of my leaderboards in TitleData. If the value is "true", then there is an active leaderboard.
For example:
I use client API GetTitleData to retrieve the key/value pairs of my currently active leaderboards: Leaderboard-1-1, Leaderboard-1-3, Leaderboard-1-7.
After that, which client API call should I use to get the remaining time of each of those three leaderboards? Is it possible to do this in one API call? Can I use PlayFabClientAPI.GetLeaderboard?
I want to display the remaining time for each leaderboard like this:
Days/Hours/Minutes/Seconds
Is it necessary to calculate the remaining time of each leaderboard myself or does PlayFab already have a method that automatically returns the remaining time until the next leaderboard reset?
I use this code to calculate the remaining time myself:
DateTime NextLeaderboardReset, CurrentTime; TimeSpan TimeInterval; int DaysLeft, HoursLeft, MinutesLeft, SecondsLeft; string Countdown = ""; NextLeaderboardReset = (DateTime)result.Result.NextReset; CurrentTime = DateTime.UtcNow; TimeInterval = NextLeaderboardReset - CurrentTime; Countdown = $"Time left: {TimeInterval.ToString(@"dd\:hh\:mm\:ss")}"; DaysLeft = TimeInterval.Days; HoursLeft = TimeInterval.Hours; MinutesLeft = TimeInterval.Minutes; SecondsLeft = TimeInterval.Seconds;
Edit: I have changed my code. I will store the time of the next leaderboard reset in TitleData for each leaderboard. Then, I don't need to call GetLeaderboard always when I want to get the remaining time:
https://community.playfab.com/questions/49233/how-can-i-get-titledata-json-value-in-the-client.html