ShowAllClientsInRoom(room_name ) and callback_ShowAllClientsInRoom()

Description

This function tells you about all the clients in a room. Enter the room name you want to check for.

Syntax

ShowAllClientsInRoom(room_name);

Returns

N/A

How do I see which clients are on this room

After a successful scan of the room name you entered, the callback function callback_ShowAllClientsInRoom() is called. So under Scripts/Rocket Networking/Callback Functions , you can edit this to do whatever you want…

❓ This function returns an array of all client id’s in a room. For example if there are 3 clients with clientId’s 3, 6 and 11 respectively in the room “public”, this function’s callback will return the array [ “3” , “6” , “11” ] . It is worth noting that these are not numbers in the array, they are strings of the numbers.

Example Implementation of function call

  • So firstly I made 2 clients join the room “public”

  • Then I wrote some basic code to try out this function

Example Implementation of callback(continued)

  • Then after I pressed okay, this callback code took place

  • Here I’ve just done a show_message so the user is shown a dialog box with that message but you get the idea

  • So what it returned in the end was

[7,9]in public

If the room does not exist?

⚠️ If the room you entered does not exist, this callback function will not return an array. Instead the “array_of_clients” variable will be the integer -1. So a good practice would be to first check if it is an array. If not then the room doesn’t exist. If yes then treat it as an array.

Last updated