ID:166798
 
I know I've posted this before but when I said that the help didnt fix the problem, no one replied.

mob/proc/pickmob()
var/List[0]
for(var/mob/M in world)
List.Add(M.key)
M.overlays+='overlay.dmi'
M.player2=0
M.it=1
world<< "font face=arial black>font color=red>GAME:[M] is it!"
player--
return

this code picks who is it in my game but it only picks the host and I would like it to pick randomly from a list of people in the game. Any help would be greatly appreciated.
It's only picking the first player because a for loops goes logically in order. Since the first iteration of the loop may only be the first person, since the order of people may not change. You can do a random player picking algorithm by getting a list of all the players, and using <code>pick()</code> to pick a random player in the list.

var/list/players = list() // list of people playing the game

mob/verb
join_game()
players += src
// add in what happens when a player joins the game

leave_game()
players -= src
// add in what happens when a player leaves the game

proc/pickmob()
if(players > 1)
var/mob/randomPlayer = pick(players)
world << "[randomPlayer] is it!"
// do whatever to randomPlayer


~~> Unknown Person
In response to Unknown Person
thanks for the help i'm testing this out as I type this lol

runtime error: type mismatch
proc name: pickmob (/mob/proc/pickmob)
usr: KirbyAllStar (/mob)
src: KirbyAllStar (/mob)
call stack:
KirbyAllStar (/mob): pickmob()
KirbyAllStar (/mob): Begin()

this error is happening everytime I try to begin the game, any ideas why?