Game Engine and Assets Leaks

[MFPS] Battle Pass Addon

Submitted by Viirless, , Thread ID: 273833

RE: [MFPS] Battle Pass Addon

This post was last modified: 27-10-2023, 11:43 AM by websbk
#24
In order for the Pass XP to be credited to the database, you need to write your calculation method in bl_Game Finish.cs
For example, it may look like this

#if BP
        public void Passxp(Action callBack = null)
        {
            int score = bl_PhotonNetwork.LocalPlayer.GetPlayerScore();
            bool winner = bl_GameManager.Instance.isLocalPlayerWinner();
            int winScore = (winner) ? bl_GameData.Instance.ScoreReward.ScoreForWinMatch : 0;
            int timePlayed = Mathf.RoundToInt(bl_GameManager.Instance.PlayedTime);
            int scorePerTime = timePlayed * bl_GameData.Instance.ScoreReward.ScorePerTimePlayed;
            int hsscore = bl_GameManager.Instance.Headshots * bl_GameData.Instance.ScoreReward.ScorePerHeadShot;
            int tscore = score + winScore + scorePerTime;
        if (bl_DataBase.Instance != null)
          {
                int newXPS = bl_DataBase.GetLocalUserMetaData().rawData.SeasonData.PassXP;
                Debug.Log("БЫЛО" + newXPS);
                int dbdata = tscore / 100;
                int tpx = newXPS + dbdata;
                int brs = bl_DataBase.Instance.LocalUser.metaData.rawData.SeasonData.PassXP = tpx;
                bl_DataBase.Instance.SaveUserMetaData(() => { callBack?.Invoke(); });
                Debug.Log("СТАЛО" + brs);
            }
            else
                callBack?.Invoke();
      }
#endif

And in the right place to call the method Passxp();

Users browsing this thread: 1 Guest(s)