Constructor
new Server(host, options)
Properties:
Name | Type | Description |
---|---|---|
host |
string | The host WebSocket address. Example: |
connected |
boolean | Will be true if the server is connected to the WebSocket, and false otherwise. |
socket |
object | An instance of the |
console |
object | Instance of the |
players |
object | Instance of the |
currentMap |
string | Name of the current map. Keep in mind that this is a generic response from the engine and not the game itself. |
isDedicated |
boolean | Whether the server is a dedicated server or not. |
authID |
string | The SteamID of the server. |
gameTime |
number | The game time, based on the game tick. |
gameTick |
number | The current game tick. |
gameFolder |
string | The directory of the server. |
gameDescription |
string | The description of the game. Keep in mind that this is a generic response from the engine, and not the game itself. |
engineVersion |
string | The engine version that SourceMod was compilied against. |
Parameters:
Name | Type | Description |
---|---|---|
host |
string | The host WebSocket address. Example: |
options |
object | Options to provide the server. |
Methods
connect()
Connects to the server.
disconnect()
Disconnects from the server. Internally calls Socket.disconnect().
fetch() → {Object}
Fetches information about the server. Keep in mind that you must run this function to keep the server information up-to-date.
Returns:
The new server object with fetched information.
- Type
- Object
setMap(map, reason) → {Object}
Forcefully changes the current map, with an optional reason. SourceMod API Reference
Parameters:
Name | Type | Description |
---|---|---|
map |
string | Name of the new map |
reason |
string | Reason for changing the map |
Returns:
- The new server object with fetched information.
- Type
- Object
setNextMap(map) → {Object}
Sets SourceMod's internal nextmap. Same as changing sm_nextmap
. Will run Server.fetch()
, ensuring the nextMap property is updated.
SourceMod API Reference
Parameters:
Name | Type | Description |
---|---|---|
map |
string | Name of the new map |
Returns:
- The new server object with fetched information.
- Type
- Object
Events
convarChanged
Fires when a ConVar changes. SourceMod API Reference
Parameters:
Name | Type | Description |
---|---|---|
name |
string | Name of the ConVar. |
steamid |
string | New value of the ConVar. |
disconnect
Fired when the server disconnects.
ready
Fired when the connection to the server has been established.