ID:144766
 
Code:
var/list/players = new/list() // list of people playing the game

proc/PickRandomPlayer()
var/list/players=list()
for(var/client/c) players+=c.mob//Loop through all clients in world, and add their mob to a list
if(!players.len) return //If there aren't any players in the world, bail out.
var/mob/M = pick(players) //Grab a random mob from the list of players.
world << "[M] is it!"
M.overlays+='overlay.dmi'
M.player2=0
M.it=1
player--
return


This always picks the same person to be IT every game, It should pick the player at random...any advice?

How are you calling it? You might be calling it when there is only 1 player in the game. You should debug the members of the list.
In response to Justin B (#1)
it doesn't pick until I begin the game, so it should randomly pick from all the players in the game at the time
KirbyAllStar wrote:
Code:
> var/list/players = new/list() // list of people playing the game
>
> proc/PickRandomPlayer()
> var/list/players=list()
> for(var/mob/c)if(c.client)players+=c//try looping through the mobs in the world, checking if they have clients then adding them to the list.
> if(!players.len) return //If there aren't any players in the world, bail out.
> var/mob/M = pick(players) //Grab a random mob from the list of players.
> world << "[M] is it!"
> M.overlays+='overlay.dmi'
> M.player2=0
> M.it=1
> player--
> return
>


Try looping through the mobs in the world, checking if they have clients then adding them to the list. It might not be the best way of doing it but it should work a tad bit better than sifting through the clients.