Store team by masterServer
marf
✭
Hi, I have a problem when a plyer join an existing room he can't see the name of the players that were there before, because when I call the rpc to assign the team he wasn't here.
What I should do?
What I should do?
0
Comments
-
Hi Marf, you dont have to, just use PhotonNetwork.playerList.name and PhotonNetwork.playerName0
-
Thanks friuns this helped me, but what I need to do to recognize the player that I want to assign the team in the PlayerList?0
-
photonView.RPC(,PhotonTargets.AllBuffered); sends to all players and who joins after
and you can check cs source code that i sended you how there it done0 -
Yeah I now, I use this code:
player.GetComponent<PhotonView>().RPC("SetTeam", PhotonTargets.AllBuffered, "AlphaTeam");
for example if someone join the match, but if this RPC was sent before the player join, it can't work.
Your code is rimilar to mine:public void OnPhotonPlayerConnected(PhotonPlayer player) { if (!PhotonNetwork.isMasterClient) return; CallRPC(SetTeam, player, (int)PlType); } [RPC] public virtual void SetTeam(int team) { TeamPath = pv.team = (Team)team; }
My RPC is this:
[RPC]void SetTeam(string TeamName) { if (networkView.isMine) { Debug.Log("SetTeam RPC e TeamName: " + TeamName); gameObject.GetComponent<ThirdPersonNetwork>().team = TeamName; } }
but it works only for seeing player that haven't joined before me.0 -
hm dont get it, remove IsMine0
-
I got the same error, I don't know why...0
-
Hi guys,
This should be relatively easy by indeed having every player send a AllBuffered(/OthersBufferd) message as soon as it has picked its team.
Could you possibly paste the latest code that you are using? as I see you both have made some changes in this thread already.0 -
Now I think that the code works, but all players are in AlphaTeam, what I need to do to get it randomly (not random in effect, beacuse I need to find what team the last player joined and then join the opposite).
I've attached the code in this post: viewtopic.php?f=17&t=1239 with the error...0