Creeper9207

hi

Nov 2nd, 2015
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. arg={...}
  2. p="default"
  3. --config
  4. ip="auto"
  5. --set manually to friend's ip for long distance connections
  6.  
  7. if ip=="auto" then
  8. http.request("http://212.1.211.216/network/get_ip.php")
  9. url, body, stuff=os.pullEvent("http_success")
  10. ip=stuff.readAll()
  11. end
  12.  
  13. function ctn_wait()
  14. while true do
  15. evt, id, message, protocol, toid=os.pullEvent("creepertech_network_receive")
  16. if toid=="default" then
  17. if protocol==p then
  18. return id, message, protocol
  19. end
  20. end
  21. if toid==tostring(os.getComputerID()) then
  22. if protocol==p then
  23. return id, message, protocol
  24. end
  25. end
  26.  
  27.  
  28. end
  29.  
  30.  
  31. end
  32. function ctn_dowait()
  33. sleep(s)
  34. end
  35. function receive(pf, xf)
  36.  
  37. if xf then
  38. s=xf
  39. p=pf
  40. parallel.waitForAny(ctn_dowait, ctn_wait)
  41. return id, message, protocol
  42. end
  43. if pf then
  44. p=pf
  45. return wait()
  46. end
  47. return wait()
  48. end
  49.  
  50. function send(recid, msg, proto)
  51. if proto then
  52. ip=textutils.urlEncode(ip)
  53. msg=textutils.urlEncode(msg)
  54. proto=textutils.urlEncode(proto)
  55. recid=textutils.urlEncode(recid)
  56.  
  57. http.request("http://212.1.211.216/network/packet_send.php?ip="..ip.."&data="..msg.."&id="..os.getComputerID().."&protocol="..proto.."&toid="..recid)
  58. return true
  59. end
  60. http.request("http://212.1.211.216/network/packet_send.php?ip="..ip.."&data="..msg.."&id="..os.getComputerID().."&toid="..recid)
  61. end
  62. function broadcast(msg, proto)
  63. if proto then
  64. ip=textutils.urlEncode(ip)
  65. msg=textutils.urlEncode(msg)
  66. proto=textutils.urlEncode(proto)
  67. --recid=textutils.urlEncode(recid)
  68.  
  69. http.request("http://212.1.211.216/network/packet_send.php?ip="..ip.."&data="..msg.."&id="..os.getComputerID().."&protocol="..proto)
  70. return true
  71. end
  72. http.request("http://212.1.211.216/network/packet_send.php?ip="..ip.."&data="..msg.."&id="..os.getComputerID())
  73. end
  74.  
  75. broadcast(arg[0], "1")
Advertisement
Add Comment
Please, Sign In to add comment