Advertisement
Syndran

server status

Mar 6th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local inet = require("internet")
  2.  
  3. --make a request to the API server
  4. local req = inet.request("https://api.mcsrvstat.us/1/TheGeekShackATM3Remix.nn.pe")
  5.  
  6. --some variables to fill, we really only need testout and resp
  7. local resp = ""
  8. local newtest = 0
  9.  
  10. --for each line in request response. append to a text line
  11. for line in req do
  12. resp = resp .. line .. "\n"
  13. end
  14.  
  15.  
  16. --get a substring, from response, starting at where online occurs +7, and finishing 2 characters later
  17. --testout = string.sub(resp,string.find(resp,"online")+7,string.find(resp,"online")+9)
  18.  
  19.  
  20. newtest = string.match(resp,"online..(%d)")
  21.  
  22.  
  23. --this is the full text.. spammy
  24. --print(resp)
  25.  
  26. --print("online count" .. testout)
  27. print("Online Count: " .. newtest)
  28. --convert to number
  29. newtest = tonumber(newtest)
  30.  
  31. --test logic for machine on/off
  32. if newtest <= 3 then
  33. print("not many players on, LAG THE FUCKERS!")
  34. else
  35. print("better be nice")
  36. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement