server.browser
The server browser library.
Functions
server.browser.addFavorite | Adds the given server address to the player's favorites. |
server.browser.getPlayers | Queries a server for its player list. |
server.browser.isBlacklisted | Checks if the server address is blacklisted by Garry's Mod. |
server.browser.isFavorite | Checks if the given server address is in the player's favorites. |
server.browser.ping | Queries a server for its information/ping. |
server.browser.query | Queries the master server for the server list. |
server.browser.removeFavorite | Removes the given server address from the player's favorites. |
server.browser.requestPing | Starts a query of a server for its information/ping, without waiting for it. |
server.browser.requestPlayers | Starts a query of a server for its player list, without waiting for it. |
#server.browser.addFavorite
function server.browser.addFavorite(address?: string)
Adds the given server address to the player's favorites.
Parameters
| Name | Type | Description |
|---|---|---|
addressoptional | string | The address of the server, current server if nil. ( IP:Port like 127.0.0.1:27015 ) |
#server.browser.getPlayers
async function server.browser.getPlayers(address: string, timeout?: ( number | false )?): server.Player[]
Queries a server for its player list.
Parameters
| Name | Type | Description |
|---|---|---|
address | string | The address of the server. ( IP:Port like 127.0.0.1:27015 ) |
timeoutoptional | ( number | false )? | The timeout in seconds, default is 30, false to disable the timeout. |
Returns
| Type | Name | Description |
|---|---|---|
server.Player[] | players | The players on the server. |
#server.browser.isBlacklisted
function server.browser.isBlacklisted(address: string): boolean
Checks if the server address is blacklisted by Garry's Mod.
Parameters
| Name | Type | Description |
|---|---|---|
address | string |
Returns
| Type | Name | Description |
|---|---|---|
boolean |
#server.browser.isFavorite
function server.browser.isFavorite(address?: string): boolean
Checks if the given server address is in the player's favorites.
Parameters
| Name | Type | Description |
|---|---|---|
addressoptional | string | The address of the server, current server if nil. ( IP:Port like 127.0.0.1:27015 ) |
Returns
| Type | Name | Description |
|---|---|---|
boolean | is_favorite | true if the given server is in player favorites, false if not. |
#server.browser.ping
async function server.browser.ping(address: string, timeout?: ( number | false )?): server.Info
Queries a server for its information/ping.
Parameters
| Name | Type | Description |
|---|---|---|
address | string | The address of the server. ( IP:Port like 127.0.0.1:27015 ) |
timeoutoptional | ( number | false )? | The timeout in seconds, default is 30, false to disable the timeout. |
Returns
| Type | Name | Description |
|---|---|---|
server.Info | info | The server information. |
#server.browser.query
function server.browser.query(data: server.QueryData)
Queries the master server for the server list.
Parameters
| Name | Type | Description |
|---|---|---|
data | server.QueryData | The query data to send to the master server. |
#server.browser.removeFavorite
function server.browser.removeFavorite(address?: string)
Removes the given server address from the player's favorites.
Parameters
| Name | Type | Description |
|---|---|---|
addressoptional | string | The address of the server, current server if nil. ( IP:Port like 127.0.0.1:27015 ) |
#server.browser.requestPing
function server.browser.requestPing(address: string, timeout?: ( number | false )?): Future<server.Info>
Starts a query of a server for its information/ping, without waiting for it.
Several requests can be awaited together with futures.all.
Parameters
| Name | Type | Description |
|---|---|---|
address | string | The address of the server. ( IP:Port like 127.0.0.1:27015 ) |
timeoutoptional | ( number | false )? | The timeout in seconds, default is 30, false to disable the timeout. |
Returns
| Type | Name | Description |
|---|---|---|
Future<server.Info> | future | The future of the server information. |
#server.browser.requestPlayers
function server.browser.requestPlayers(address: string, timeout?: ( number | false )?): Future<server.Player[]>
Starts a query of a server for its player list, without waiting for it.
Several requests can be awaited together with futures.all.
Parameters
| Name | Type | Description |
|---|---|---|
address | string | The address of the server. ( IP:Port like 127.0.0.1:27015 ) |
timeoutoptional | ( number | false )? | The timeout in seconds, default is 30, false to disable the timeout. |
Returns
| Type | Name | Description |
|---|---|---|
Future<server.Player[]> | future | The future of the player list. |