I am trying to the get the BasePlayer of a random player.
The problem is not getting the BasePlayer, the problem is making it random.
I thougt maybe something like this
But that will give a number. Maybe looping through all players, but I don't know.Code:int playeraleatorio; playeraleatorio = UnityEngine.Random.Range(0, BasePlayer.activePlayerList.Count); PrintToChat(playeraleatorio);
I am not asking for someone to make the code, I am asking for an idea.
Thanks.
[DOUBLEPOST=1465953696][/DOUBLEPOST]Solved.
That code is from RGive. It works, but I don't know why there is a "-1" at the end.Code:BasePlayer GetRandomPlayer() => BasePlayer.activePlayerList[UnityEngine.Random.Range(0, BasePlayer.activePlayerList.Count - 1)];
Solved Getting a random player?
Discussion in 'Rust Development' started by Reynostrum, Jun 15, 2016.