Guest User

location

a guest
Oct 8th, 2014
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.60 KB | None | 0 0
  1. --get IP
  2. local website = http.get("http://l2.io/ip.js?var=myip")
  3. local ip = website.readAll()
  4.  
  5. local ip = ip:gsub(";","")
  6. local ip = ip:gsub('"',"")
  7. local ip = ip:gsub("=","")
  8. local ip = ip:gsub("myip","")
  9. local ip = ip:gsub(" ","")
  10.  
  11. --turn IP into location
  12. --Note: IP is just a place holder for
  13. --if it doesn't let us get the IP and
  14. --get the location in one function
  15.  
  16. local locr = http.get("http://api.hostip.info/country.php?ip="..ip.."")
  17. local loc = locr.readAll()
  18. --if the location is private
  19. if loc == "XX" then
  20. print("Location private.")
  21. else --otherwise, if it's not private
  22. print(loc)
  23. end
Advertisement
Add Comment
Please, Sign In to add comment