ID:179380
 
I need a way to list the people in the room, but after browsing through the refrence, I didn't see a command to automate this (naturally ^_^), so does anyone know of a way to do it? You don't have to copy-paste code, juts explain it if you can. Thanx :)
Dreq wrote:
I need a way to list the people in the room, but after browsing through the refrence, I didn't see a command to automate this (naturally ^_^), so does anyone know of a way to do it? You don't have to copy-paste code, juts explain it if you can. Thanx :)

Check out the view() proc.
In response to Deadron
This seems to only return the users in your current vision. What if the users are on another layer or out of your vision?
In response to Dreq
What exactly do you mean by players in the "room"?
In response to Dreq
Dreq wrote:
This seems to only return the users in your current vision. What if the users are on another layer or out of your vision?

Another layer won't matter, unless you're talking about a z coordinate. You might want also to check out range().
In response to Foomer
Yes i'm talking about Z Layer
In response to Dreq
Dreq wrote:
Yes i'm talking about Z Layer

Well then you aren't talking about the traditional definition of a "room"...so as Foomer suggests, you should first describe what you mean by a room.
In response to Dreq
Hmm, the best thing I can think of (someone else can probably do better) is something like this:

Add all players to the Players list when the log in.

var/list/Players = list()
mob/Login()
..()
Players += usr

mob/Logout()
..()
Players -= usr

proc/Zlayer(mob/M)
var/list/Zlayer = list()
for(var/mob/P in Players)
if(P.z == M.z) Zlayer += P
return Zlayer
then:

Zlayer(usr) << "Whatever."
That will send the message to all mobs on the Z layer equal to the mob you specify in the ()'s.
In response to Deadron
I guess in this sense, I define a 'room' as a zlayer :)
In response to Dreq
Dreq wrote:
I guess in this sense, I define a 'room' as a zlayer :)

Then you pretty much need to do what Foomer suggests.

I'll of course recommend that you use the Players library to keep your list of players:

byond://Deadron.Players

Then you could do a say verb like so:

verb/say(message as text)
for (var/mob/M in base_PlayerMobs())
if (M.z == z)
M << "[src]: [text]"
In response to Deadron
var/tmp/mob/M
for(M)
if (M.client)
src << "[M.name]"

:)