Hi!
I need to get random steamid from players.
I dont know how to use this:
Code:void getRandomPlayer(PlayerSession player, NetworkPlayer n) { Player.Sessions.Random(n, player); }
Getting a random player's Steam ID?
Discussion in 'Hurtworld Development' started by 531devv, May 30, 2017.
-
Hello @5311,
What do you exactly want?
You want a random steam id out of all online players? -
@Mr. Blue
Yes I need get random steamid out of all online players. -
Hi @5311,
I think this should do...
Code:void getRandomPlayerId() { var allPlayers = GameManager.Instance.GetSessions().Values.ToList(); if (allPlayers.Count() > 0) { int randomInt = UnityEngine.Random.Range(0, allPlayers.Count()); var playerId = allPlayers[randomInt].SteamId.ToString(); Puts("RANDOM: " + playerId); } else { Puts("No online players"); } }
Last edited by a moderator: May 30, 2017 -
Thanks!!