ID:2190916
 
(See the best response by Kaiochao.)
Code:
                for(var/mob/player/M in players)
var/mob/player/p//null//pick(p1,p2,p3,p4)//pick(p1 in players, p2 in players, p3 in players, p4 in players)
var/ppick=rand(1,4)
if(ppick==1) p=p1
if(ppick==2) p=p2
if(ppick==3) p=p3
if(ppick==4) p=p4
sleep(1)
if(M==p)
// spawn()
sleep(130)
//sleep(130)
if(p.client) p.client.screen+=i2
sleep(20)//leep(15)
if(p.client)
p.client.screen-=i2
if(!w1)
w1=p
character("werewolf", p)


Problem description:
Alright. I've played with this code for hours upon hours. It worked, then I adjusted it, then everyone became the wolf on startup, then I thought I had fixed it again but upon revision it was bugged and just always making player 4 the werewolf.

I'm not doing this correctly. I've tried many different ways, all of which are not proving to be successful. Can someone give me a simple way of handling this? I felt like a simple pick() from the list of active players would be suffice but have tried so much more then that since I started dabbling with this.
This piece of code has been changed so much that p & M are probably not being used as they originally were intended to be used.
Hard to tell what you're actually trying to do here.
Not surprised! It's terrible code. Ok.

All players are put in a list, players. There also are world vars for each character slot(p1-p4).

This code is called a minute after a player logs in and if there are 4 players are on the map. The hunger cycle and darkness cycle are also called at this time.

What this code is suppose to do is pick 1/4 of the players and change them into the Werewolf. It also gives a notification to the werewolf seconds before he/she turns.
Best response
The for() is unnecessary; you're not trying to repeat any code "for each" player.
var mob/player/player = pick(players)
player << "you're turning into a werewolf"
sleep seconds*10
change_into_werewolf(player)
I really don't think it's wise that p1 through p4 be separate vars, rather than a list. That's a big part of the problem IMO.
Thanks for the help guys!