GetServerIpFromMasterServer

From Multi Theft Auto: Wiki
Jump to navigation Jump to search

ADDED/UPDATED IN VERSION 1.6.0 r22890:
This function returns the remote address as reported by the first master server that provides this value.
[[{{{image}}}|link=|]] Note: It might take a while until the master server responds to the query sent out by the server, which in turn means that this function will not return any IP until the information has been received.
[[{{{image}}}|link=|]] Note: On client-side there is the getServerIp function, in case you need the remote address of the currently connected server.
[[{{{image}}}|link=|]] Note: If you want to retrieve the server IP address from the server configuration, then you should use getServerConfigSetting("serverip"), but this might yield only "auto" if the default value was used.

Syntax

string getServerIpFromMasterServer ( )

Returns

A string containing the remote address of the server as reported, once it's available.

Example

This example creates a console command that outputs the server's IP to the chatbox.

function outputServerIp()
    outputChatBox(getServerIpFromMasterServer())
end

addCommandHandler("serverIp", outputServerIp)

See Also