Randchar

     randchar - syntax: randchar(options) 

Returns a random char from the current room as a CH type variable. Candidates for selection are filtered based on the options provided. It is essential always to test for nil result after using randchar.

  LP_SEEALL No visibility checks, all chars in the room can be selected. 
  LP_MOBONLY Only consider mobs in the room. 
  LP_PLRONLY Only consider players in the room. 


   --- Select a random player, inform the room and the target.
   local rchar = randchar(LP_PLRONLY)
   --- If we didn't find anyone, bail.
   if rchar == nil then return end

   --- Note how with rchar passed to echo as the 'about' char, 
   --- it becomes the base char for $N/$S/etc variables.
   echo("$n has picked $N as $s target!",rchar)

   --- Now send a message to the character themselves.
   echoat(rchar,"Congratulations, you're the lucky target!")