ID:269797
 
How do I have the game pick one player out of the players in the game and then change a var of theirs and possibly send that person a message? Do I have to generate a list of the players I want the game to pick out of?
Make a list to hold all the players in the game, like so...
var/list/people=new()

Now, use for() to loop through every player in the game, and also use if(M.client) to check to see if they truly are a player, unless you want non-players to show up in the list as well, like so:
for(var/mob/M in world) // Loop through every mob in the world
if(M.client) // if they are a client
if(M==src) return // Remove this if you don't want the person calling the verb to be removed from the list of players.
people+=M // Add them to the list.

Next, to access the list and allow the player that activated the verb to choose someone in the world, or however you wanted it done, use input(). (Only if you intend to let one player choose another) Like so:
var/player=input(src,"Whom do you wish to pick?","Pick a Player") in people // Let the person choose someone

Next, loop through all the people in the world and find the one matching the player var. Like so:
for(var/mob/P in world) // Loop through every person in the world again
// if P is player
if(P==player)
P.psvar = anumber // Change one of P's(the players) vars.

Hope this helps. :-)
In response to KingSerpent
The top half helps, but the bottom half wasn't really what I wanted. I want the GAME to pick a person randomly without the PLAYERS knowing about it and change a var of the person and send that person a message telling them that they've been selected.
Or, if you want the game to do everything automatically (I think you did anyway) you'd do something like this:
var/list/players=new() // Make a new list for players.
for(var/mob/M in world) // Add each mob, if they are a player, to the players list.
if(M.client) players+=M
var/mob/player=pick(players) // Pick a player in the players list
player.strength+=5 // Edit a var of theirs.
player << "Tehhehehe, ur strangth has ban upperd by 5! LOL"


:-)
In response to KingSerpent
Thanks, KingSerpent, I was not very familiar with lists.
In response to Justin Knight
Yar, lists are a wonderful thing in DM.