victormgons Posted July 15, 2015 Share Posted July 15, 2015 Hi, i'm tring to use a funcion to get the server IP. I tried this https://wiki.multitheftauto.com/wiki/GetServerIp But it's not working, I changed the website, but every returns nil. Someone can help me? function getServerIp() callRemote("box.houkouonchi.jp/ip.php",function(ip) return ip end) end Link to comment
GTX Posted July 15, 2015 Share Posted July 15, 2015 function getServerIP() fetchRemote("yourwebsite.com/ip.php",function(ip) return ip end) end Put this on your webserver: <?php echo $_SERVER['REMOTE_ADDR']; ?> Link to comment
victormgons Posted July 15, 2015 Author Share Posted July 15, 2015 It isn't working yet, it returns NIL in the chatbox Link to comment
victormgons Posted July 15, 2015 Author Share Posted July 15, 2015 http://prntscr.com/7t0aec The LUA code is: function getServerIP() fetchRemote("192.168.0.101/getServerIP.php",function(ip) return ip end) end outputChatBox(getServerIP()) Link to comment
GTX Posted July 15, 2015 Share Posted July 15, 2015 Mhm, try: function getServerIP() return fetchRemote("192.168.0.101/getServerIP.php",function(ip) return ip end) end outputChatBox(getServerIP()) Link to comment
victormgons Posted July 15, 2015 Author Share Posted July 15, 2015 The error is the same, but when i used outputChatBox(tostring(getServerIP())) it returns "true" Link to comment
GTX Posted July 15, 2015 Share Posted July 15, 2015 The point is, you can't return from the same function where fetchRemote is. Blame MTA developers, lol. function getServerIP() fetchRemote("192.168.0.101/getServerIP.php", returned) end function returned(ip) outputChatBox(ip) end Link to comment
victormgons Posted July 15, 2015 Author Share Posted July 15, 2015 Finally worked men. But, how can I use an verification? I tried this but not worked http://prntscr.com/7t0m8k function getServerIP() fetchRemote("192.168.0.101/getServerIP.php", returned) end function returned(ip) if ip == 192.168.0.101 then outputChatBox(ip) end end getServerIP() Link to comment
victormgons Posted July 15, 2015 Author Share Posted July 15, 2015 Done, thank you so much! function getServerIP() fetchRemote("192.168.0.101/getServerIP.php", returned) end function returned(ip) ip = ip:gsub(' ', '') if ip == "192.168.0.101" then outputChatBox(ip) end end getServerIP() 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now