Set custom properties, help-me!!!

Hello guys,

I am creating a game 2d Multiplayer through the photon, and until then I did not have any problems, due to the tutorials I watched on youtube, but now I have a maddening doubt, I would like to know how to create a script to define the customization of a player, this whole script based on integer values, example

    static public float ModelNariz;

void Update ()
{
  // ---------------------------------------
        if (AUXModelNariz == 1)
        {
            NARIZ1.SetActive (true); NARIZ2.SetActive (false); NARIZ3.SetActive (false); NARIZ4.SetActive (false);
        }
        if (AUXModelNariz == 2)
        {
            NARIZ1.SetActive (false); NARIZ2.SetActive (true); NARIZ3.SetActive (false); NARIZ4.SetActive (false);
        }
        if (AUXModelNariz == 3)
        {
            NARIZ1.SetActive (false); NARIZ2.SetActive (false); NARIZ3.SetActive (true); NARIZ4.SetActive (false);
        }
        if (AUXModelNariz == 4)
        {
            NARIZ1.SetActive (false); NARIZ2.SetActive (false); NARIZ3.SetActive (false); NARIZ4.SetActive (true);
        }
 }



    public void AVANCOMODELONARIZ ()
    {
        my.RPC ("AMN", PhotonTargets.AllBuffered);
        ColorsBasic.AUXSELECT = 7;
        if (ColorsBasic.AUXModelNariz <= 5)
            ColorsBasic.AUXModelNariz = ColorsBasic.AUXModelNariz + 1;
        if (ColorsBasic.AUXModelNariz == 5)
            ColorsBasic.AUXModelNariz = 1;
    }


    public void RECUOMODELONARIZ ()
    {
        my.RPC ("NMR", PhotonTargets.AllBuffered);
        ColorsBasic.AUXSELECT = 7;
        if (ColorsBasic.AUXModelNariz> = 1)
            ColorsBasic.AUXModelNariz = ColorsBasic.AUXModelNariz - 1;
        if (ColorsBasic.AUXModelNariz == 0)
            ColorsBasic.AUXModelNariz = 4;
    }




    [PunRPC]
    public void AMN ()
    {


        ColorsBasic.AUXSELECT = 7;
        if (ColorsBasic.ModelNariz <= 5)
            ColorsBasic.ModelNariz = ColorsBasic.ModelNariz + 1;
        if (ColorsBasic.ModelNariz == 5)
            ColorsBasic.ModelNariz = 1;

    }
    [PunRPC]
    private void RMN ()
    {


        ColorsBasic.AUXSELECT = 7;
        if (ColorsBasic.ModelNariz> = 1)
            ColorsBasic.ModelNariz = ColorsBasic.ModelNariz - 1;
        if (ColorsBasic.ModelNariz == 0)
            ColorsBasic.ModelNariz = 4;
    }



what disturbs me is that although this method works, when in my avatar customization screen for example the nose model, this is performed in all copies of the game, which causes a lot of confusion because it hinders the customization of other players, I researched for days a method of sending information (DO MY PLAYER) to the other copies of the game without interfering with them, I found something that might help me called (Set custom properties), but I have no idea how to use it, could anyone give me any tips on how I could do this, and if the only way is through Set custom properties

Comments

  • f03n1x
    f03n1x
    edited July 2018
    Setting custom properties is pretty easy, here is an example:
    ExitGames.Client.Photon.Hashtable playerCustomization = new ExitGames.Client.Photon.Hashtable();
    playerCustomization["AUXModelNariz"] = 1;//set the information here, it could be 2, 3, etc
    PhotonNetwork.player.SetCustomProperty(playerCustomization);

    Retrieving the information is just as easy:
    int AUXModelNariz = PhotonNetwork.player.CustomProperties["AUXModelNariz"]; 
    // this string in brackets has to be the same as the set name, since they are the key that is passed over the network
    You will have to do this for each player (that's the whole idea around PhotonNetwork.player) which should be simple enough to do. You can do the same thing but for room specific information, like for example if each room had a different map, the only difference is setting the custom property to PhotonNetwork.room, instead of PhotonNetwork.player.