Help with random player sytem
Options
iamE
✭
I got this code when I asked a question earlier about selecting a random player and TaggedPlayer is a string so I can't get a .GetComponent and stuff from it. Does anyone know how to fix this?
using System.Collections.Generic;
public List<string> PlayerList = new List<string>();
We can call PlayerConnected
void OnPhotonPlayerConnected(){
if (!PlayerList.Contains (PhotonNetwork.playerName)) {
PlayerList.Add (PhotonNetwork.playerName);
}
}
Next We Need A Pick Random Method to Invoke
void TagRandomPlayer(){
int PlayerListRange = PlayerList.Count;
System.Random Rand = new System.Random ();
int RandomPick = Rand.Next (0, PlayerListRange);
string TaggedPlayer = PlayerList [RandomPick];
}
using System.Collections.Generic;
public List<string> PlayerList = new List<string>();
We can call PlayerConnected
void OnPhotonPlayerConnected(){
if (!PlayerList.Contains (PhotonNetwork.playerName)) {
PlayerList.Add (PhotonNetwork.playerName);
}
}
Next We Need A Pick Random Method to Invoke
void TagRandomPlayer(){
int PlayerListRange = PlayerList.Count;
System.Random Rand = new System.Random ();
int RandomPick = Rand.Next (0, PlayerListRange);
string TaggedPlayer = PlayerList [RandomPick];
}
0
Comments
-
Can someone please help?0
-
Sorry, we can only help with coding problems when we really have the time for it. At the moment, we're too busy to write working code for anyone else. For us it's way faster to write pseudo code and let you do the exact implementation.
You might be faster learning a bit more about C# programming and about fixing any errors you get when you compile things.
You don't even write what exactly is going wrong. You just paste pseudo-code.0 -
Tobias wrote:Sorry, we can only help with coding problems when we really have the time for it. At the moment, we're too busy to write working code for anyone else. For us it's way faster to write pseudo code and let you do the exact implementation.
You might be faster learning a bit more about C# programming and about fixing any errors you get when you compile things.
You don't even write what exactly is going wrong. You just paste pseudo-code.0