PDA

View Full Version : get user details from getUsersInRoom



bucko
12-06-2007, 09:14 AM
I'm trying to get the details of all the users in a room by way of the room plugin.

//I think this bit is ok...
var zoneId = getApi().getZoneId();
var roomId = getApi().getRoomId();
var usersArr = getApi().getUsersInRoom(zoneId,roomId).toArray();

//now i'm not sure...
for (var i in usersArr)
{
// trace the username and any uservariables
}

Thanks.
And double thanks for all your prompt replies to my queries!

jobem
12-06-2007, 09:36 AM
Hi Bucko,

The docs for that are here:
http://www.electro-server.com/documentation/docs/es4/server/extension/com/electrotank/electroserver4/extensions/api/ElectroServerApi.html#getUsersInRoom(int, int)

The method returns a Collection, which is a type of ordered list. Each element is of type UserValue. You can loop through the list like this:



var zoneId = getApi().getZoneId();
var roomId = getApi().getRoomId();
var usersArr = getApi().getUsersInRoom(zoneId,roomId).toArray();
for (var i=0;i<usersArr.size();++i) {
var user = usersArr.get(i);
//user.getUserName();
}