victormgons Posted July 15, 2015 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
GTX Posted July 15, 2015 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']; ?>
victormgons Posted July 15, 2015 Author Posted July 15, 2015 It isn't working yet, it returns NIL in the chatbox
victormgons Posted July 15, 2015 Author 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())
GTX Posted July 15, 2015 Posted July 15, 2015 Mhm, try: function getServerIP() return fetchRemote("192.168.0.101/getServerIP.php",function(ip) return ip end) end outputChatBox(getServerIP())
victormgons Posted July 15, 2015 Author Posted July 15, 2015 The error is the same, but when i used outputChatBox(tostring(getServerIP())) it returns "true"
GTX Posted July 15, 2015 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
victormgons Posted July 15, 2015 Author 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()
victormgons Posted July 15, 2015 Author 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
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