2021-01-23 08:49:04 -08:00
|
|
|
# multiserver API
|
|
|
|
A multiserver RPC API for Minetest Servers
|
2021-01-23 08:58:00 -08:00
|
|
|
## multiserver project
|
|
|
|
This project is intended for use in combination with [multiserver](https://github.com/HimbeerserverDE/multiserver).
|
2021-01-23 08:49:04 -08:00
|
|
|
## Usage
|
|
|
|
Install this mod on your minetest servers and enable mod channels on
|
|
|
|
each server. You can now use the API in your own mods.
|
|
|
|
## Methods
|
|
|
|
> `multiserver.alert(msg)`
|
|
|
|
```
|
|
|
|
msg: Message to send
|
|
|
|
Description: Sends msg to all clients that are connected to the proxy
|
|
|
|
```
|
|
|
|
> `multiserver.get_default_server(callback)`
|
|
|
|
```
|
|
|
|
callback: Callback function (params: default_server)
|
|
|
|
Description: Gets the default server and passes it to the callback
|
|
|
|
function
|
|
|
|
```
|
|
|
|
> `multiserver.get_player_count(callback)`
|
|
|
|
```
|
|
|
|
callback: Callback function (params: player_count)
|
|
|
|
Description: Gets the count of players that are connected to the proxy
|
|
|
|
and passes it to the callback function
|
|
|
|
```
|
|
|
|
> `multiserver.is_online(name, callback)`
|
|
|
|
```
|
|
|
|
name: Player name to use for check
|
|
|
|
callback: Callback function (params: is_online)
|
|
|
|
Description: Reports to the callback function if a player is online
|
|
|
|
```
|
|
|
|
> `multiserver.check_privs(name, privs, callback)`
|
|
|
|
```
|
|
|
|
name: Player name to use for check
|
|
|
|
privs: Privileges the player has to have
|
|
|
|
callback: Callback function (params: has_privs)
|
|
|
|
Description: Reports to the callback function if a player has the
|
|
|
|
specified privileges
|
|
|
|
```
|
2021-02-28 07:33:39 -08:00
|
|
|
> `multiserver.get_privs(name, callback)`
|
|
|
|
```
|
|
|
|
name: Player name to use for check
|
|
|
|
callback: Callback function (params: privs)
|
|
|
|
Description: Gets the proxy-level privileges of a player and passes it
|
|
|
|
to the callback function
|
|
|
|
```
|
|
|
|
> `multiserver.set_privs(name, privs)`
|
|
|
|
```
|
|
|
|
name: Player name to set privileges for
|
|
|
|
Description: Sets the proxy-level privileges of a player
|
|
|
|
```
|
2021-01-23 08:49:04 -08:00
|
|
|
> `multiserver.get_server_name(name, callback)`
|
|
|
|
```
|
|
|
|
name: Player name to perform lookup on
|
|
|
|
callback: Callback function (params: server_name)
|
|
|
|
Description: Gets the name of the server a player is currently
|
|
|
|
connected to and passes it to the callback function
|
|
|
|
```
|
|
|
|
> `multiserver.redirect(name, tosrv)`
|
|
|
|
```
|
|
|
|
name: Name of player to redirect
|
|
|
|
tosrv: Name of server to connect player to
|
|
|
|
Description: Redirects a player to the specified server
|
|
|
|
```
|
|
|
|
> `multiserver.get_address(name, callback)`
|
|
|
|
```
|
|
|
|
name: Player name to perform lookup on
|
|
|
|
callback: Callback function (params: address)
|
|
|
|
Description: Gets the address of a player (format: IP_ADDRESS:PORT) and
|
|
|
|
passes it to the callback function; This is needed because minetest
|
|
|
|
servers only see the address of the proxy
|
|
|
|
```
|
2021-02-28 10:28:09 -08:00
|
|
|
> `multiserver.is_banned(target, callback)`
|
|
|
|
```
|
|
|
|
target: IP address to perform check on
|
|
|
|
callback: Callback function (params: is_banned)
|
|
|
|
Description: Reports to the callback function if a player is banned
|
|
|
|
```
|
|
|
|
> `multiserver.ban(target)`
|
|
|
|
```
|
|
|
|
target: Name or IP address to ban
|
|
|
|
Description: Bans a player, can only use name if the player is online
|
|
|
|
```
|
|
|
|
> `multiserver.unban(target)`
|
|
|
|
```
|
|
|
|
target: Name or IP address to unban
|
|
|
|
Description: Unbans a player
|
|
|
|
```
|
2021-03-17 09:32:04 -07:00
|
|
|
> `multiserver.get_servers(callback)`
|
|
|
|
```
|
|
|
|
callback: Callback function (params: srvs)
|
|
|
|
Description: Returns an indexed table containing all server names
|
|
|
|
to the callback function
|
|
|
|
```
|
2021-03-17 09:48:42 -07:00
|
|
|
> `multiserver.broadcast_msg(msg)`
|
2021-01-29 09:12:58 -08:00
|
|
|
```
|
|
|
|
msg: Message to send
|
|
|
|
Description: Sends a message to all other minetest servers
|
|
|
|
```
|
2021-03-17 09:48:42 -07:00
|
|
|
> `multiserver.send_msg(tosrv, msg)`
|
|
|
|
```
|
|
|
|
tosrv: Server to send the message to
|
|
|
|
msg: Message to send
|
|
|
|
Description: Sends a message to another minetest server
|
|
|
|
```
|
2021-01-24 07:01:01 -08:00
|
|
|
> `multiserver.register_on_joinplayer(callback)`
|
|
|
|
```
|
2021-03-17 09:19:43 -07:00
|
|
|
callback: Callback function (params: name, srv)
|
2021-01-24 07:01:01 -08:00
|
|
|
Description: Registers a callback for global join events
|
|
|
|
```
|
|
|
|
> `multiserver.register_on_leaveplayer(callback)`
|
|
|
|
```
|
|
|
|
callback: Callback function (params: name)
|
|
|
|
Description: Registers a callback for global leave events
|
|
|
|
```
|
|
|
|
> `multiserver.register_on_redirect_done(callback)`
|
|
|
|
```
|
|
|
|
callback: Callback function (params: name, newsrv, success)
|
|
|
|
Description: Registers a callback function for global redirect events;
|
|
|
|
newsrv is the server the client was being redirected to, success
|
|
|
|
indicates whether the redirection was successful
|
|
|
|
```
|
2021-01-29 09:12:58 -08:00
|
|
|
> `multiserver.register_on_msg(callback)`
|
|
|
|
```
|
2021-03-17 09:48:42 -07:00
|
|
|
callback: Callback function (params: msg, broadcast)
|
2021-01-29 09:12:58 -08:00
|
|
|
Description: Registers a callback function for messages sent by other
|
2021-03-17 09:48:42 -07:00
|
|
|
minetest servers, broadcast is true if all servers were sent
|
|
|
|
the message
|
2021-01-29 09:12:58 -08:00
|
|
|
```
|