Add points to each player of winning team

  • Thanks ,this is the best asset.please I want to add points for each player from the winning team after the end of each match.can you help me

  • Welcome.

    You wrote "score" before, not "points". Do you mean you would like to give the winning team a reward, so they could buy other tanks etc. with it?

    Did you look into our other asset, Simple IAP System? It handles currency already and would be the best choice to implement virtual products. We also have a guide for integrating Simple IAP System in this section of the forum.

  • Hi.
    I have purchased the service but i have not found the solution to my problem.
    I want to add score to each player of the winning team : Score = Previous_Score + New_Score
    and the score will be saved ,whenever a player join the game the score will be loaded in the main game interface(Tank Multiplayer). thank you

  • If you are using Simple IAP System, you could use:

    DBManager.IncreasePlayerData("score", new_score);

    in order to grant players new score values. DBManager Scripting Reference

    If you do not use virtual currency at all, you could just use Unity's PlayerPrefs directly as well. It was not clear from your question. If you have trouble finding the winning team or kills for the local player, please let me know which networking provider (UNET or Photon) you are using so I can answer that with more detail.

  • Using Photon.
    At the end of each match the score is add to ekach player ofrom winner team and it must been showed on the main screen.Like the Game "TanksAlot".thanks

  • The personal kill & death score per game can be accessed from anywhere in the Game scene, via


    UIGame Scripting Reference

    To find out if the local player has won when the game is over, have a look at the Player.RpcGameOver method (at the end of the Player script). You can then do a check in there, like

    bool hasWon = this.photonView.GetTeam() == (int)teamIndex;

    If "hasWon" is true, that player is in the winning team and you can increase his score.

  • hi.this my code

            protected void RpcGameOver(byte teamIndex)
                //display game over window
                bool hasWon = this.photonView.GetTeam() == (byte)teamIndex;
                if (hasWon == true)
                    GameManager.GetInstance().ui.WinOrLose.text = "You Win";
                else if(hasWon == false)
                    { GameManager.GetInstance().ui.WinOrLose.text = "You Lose"; }

    hasWon always return false

  • Sorry, just checked the logic again. The method RpcGameOver is called on the last killed player, not on the local player, so "hasWon" will never be true.

    Do the check in the GameManager.DisplayGameOver method instead, using the localPlayer like this:

            public void DisplayGameOver(int teamIndex)
                //PhotonNetwork.isMessageQueueRunning = false;
                localPlayer.enabled = false;
                bool hasWon = localPlayer.photonView.GetTeam() == (int)teamIndex;
                if(hasWon) ui.gameOverText.text = "You Win";
                else ui.gameOverText.text = "You Lose";
                //starts coroutine for displaying the game over window

  • Thanks. It works
    But I have problems with adding the currency to every winning player, how can I save and get it using playerpref or Dbmanager

  • Our scripting reference has all methods documented that you may want to call:

    DBManager.IncreaseFunds(string currency, int value)
    DBManager.GetFunds(string currency)

    For documentation on PlayerPrefs please see Unity's official documentation.

Log in to reply