mtasa-blue
                                
                                 mtasa-blue copied to clipboard
                                
                                    mtasa-blue copied to clipboard
                            
                            
                            
                        getServerIp
Is your feature request related to a problem? Please describe.
With discord rich presence getting more adoption from scripts and servers over time, it has become common practice to want to add a button to directly join the server via tha mtasa:// protocol. In order to do so the script needs to know the ip and port of the server. Getting the port is really simple and works like a charm, however the same can't be said about the IP, which is fairly inconvenient to retrieve as outlined in the 'describe alternatives you've considered'-section.
Describe the solution you'd like
Ideally the server and client would provide a simple script function to return the server IP. The client should already know which IP it's connected to and the server could cache its IP to return whenever a script requests it.
Describe alternatives you've considered
- 
The wiki recommends to use getServerConfigSetting("serverip") which isn't exactly useful as it will just return the string 'auto' unless the server uses a manually specified IP. 
- 
Another way to retrieve the server IP is to fetch it from any IP lookup website, like checkip.dyndns.com as recommended here This is technically a great solution, except fetchRemote requires ACL rights, which I think shouldn't be required to do something as trivial as retrieving the server IP. Additionally having to rely on those services availability could potentially be annoying and the method to do it is currently very hidden on the wiki, which makes it harder for people to find. 
- 
Hard coding the ip/hostname. It's not really something I'd consider a real alternative. This works if you're making a script specifically for one server, but anyone who just makes scripts for general/public use or wants to sell them to server owners wouldn't really want to make this needlessly complicated for the other party involved. 
Additional context
No response
Security Policy
- [X] I have read and understood the Security Policy and this issue is not about a cheat or security vulnerability.
IMHO it's simpler to implement STUN function for getting IP. Or fix it for Discord Rich Presence