GetServerIpFromMasterServer: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Server function}} {{New feature/item|3.0161|1.6.0|22890|This function returns the remote address as reported by the first master server that provides this value.}} {{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.}} {{Note|On client-side there is the getServerIp function, in case you need the remote addre...")
 
mNo edit summary
 
Line 4: Line 4:
{{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.}}
{{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.}}
{{Note|On client-side there is the [[getServerIp]] function, in case you need the remote address of the currently connected server.}}
{{Note|On client-side there is the [[getServerIp]] function, in case you need the remote address of the currently connected server.}}
{{Note|If you want to retrieve the server IP address from the server configuration, then you should use <code>getServerConfigSetting("serverip")</code>, but this might yield only <code>"auto"</code> if the default value was used.}}


==Syntax==  
==Syntax==  

Latest revision as of 19:47, 8 January 2025

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