Advertisement
osmarks

CCPosCast

Mar 16th, 2019
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local a=http.get"https://raw.githubusercontent.com/rxi/json.lua/bee7ee3431133009a97257bde73da8a34e53c15c/json.lua"local b=fs.open("json","w")b.write(a.readAll())a.close()b.close()
  2. local json = require "/json"
  3. API = "https://dynmap.switchcraft.pw/up/world/world/"
  4.  
  5. local function fetch(url, headers)
  6.     local h = http.get(url, headers)
  7.     local o = h.readAll()
  8.     h.close()
  9.     return o
  10. end
  11.  
  12. local m = peripheral.find "modem"
  13.  
  14. while true do
  15.     local data = json.decode(fetch(API .. os.epoch "utc", {
  16.         Cookie = "JSESSIONID=abcd",
  17.     }))
  18.     local tosend = {}
  19.     for _, player in pairs(data.players) do
  20.         if player.world == "DIM1_the_end" then
  21.             table.insert(tosend, { player.name, player.x, player.y, player.z })
  22.         end
  23.     end
  24.     print("Broadcasting locations of", #tosend, "players")
  25.     m.transmit(1103, 1103, tosend)
  26.  
  27.     sleep(1)
  28. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement