AnonymusHochgenuss

playerlist1

Nov 13th, 2021 (edited)
1,098
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local tbl = { a = "top", b = "bottom", c = "left", d = "right", f = "front", g = "back" }
  2. table.foreach(tbl,
  3. function(k, v)
  4.  if peripheral.isPresent(v) then
  5.   if peripheral.getType(v) == "modem" then
  6.    print("open modem")
  7.    rednet.open(v)
  8.   end
  9.  end
  10. end)
  11. shell.run("clear")
  12. print("Playerlist:")
  13. print("")
  14. pid=1
  15. if not fs.exists("player"..pid) then
  16.  file=fs.open("player"..pid,"w")
  17.  name="M3veronMast3r"
  18.  file.writeLine(name)
  19.  file.close()
  20. end
  21. while fs.exists("player"..pid) do
  22.  pidt=pid
  23.  pid=1
  24.  while fs.exists("player"..pid) do
  25.   pid=pid+1
  26.  end
  27.  pid=pid-1
  28.  pidz=pid
  29.  pid=pidt
  30.  file=fs.open("player"..pid,"r")
  31.  name=file.readLine()
  32.  file.close()
  33.  if fs.exists("players") then
  34.   file=fs.open("players","r")
  35.   ppidz=tonumber(file.readLine())
  36.   if ppidz > pidz then
  37.    pidz = ppidz
  38.   end
  39.   file.close()
  40.  end
  41.  pidx=pid
  42.  online=false
  43.  id, text = rednet.receive()
  44.  if id == 39 then
  45.   table.foreach(text,
  46.   function(k, v)
  47.    if v == name then
  48.     online = true
  49.     if not fs.exists(name) then
  50.      file=fs.open(name,"w")
  51.      Last=1
  52.      file.writeLine(Last)
  53.      file.close()
  54.     end
  55.    end
  56.    if not fs.exists(v) then
  57.     t=1
  58.     for i=1,pidz do
  59.      file=fs.open("player"..pidz,"r")
  60.      if file.readLine == v then
  61.       file.close()
  62.       file=fs.open(v,"w")
  63.       Last=1
  64.       file.writeLine(Last)
  65.       file.close()
  66.       t=0
  67.      else
  68.       file.close()
  69.       if i == pidz then
  70.        if t > 0 then
  71.         pidt=pid
  72.         pid=pidz
  73.         pid=pid+1
  74.         file=fs.open("player"..pid,"w")
  75.         file.writeLine(v)
  76.         pidz=pidz+1
  77.         pid=pidt
  78.         file.close()
  79.         file=fs.open(v,"w")
  80.         Last=1
  81.         file.writeLine(Last)
  82.         file.close()
  83.         t=0
  84.        end
  85.       end
  86.      end
  87.     end
  88.    end
  89.   end)
  90.  end
  91.  if not online == true then
  92.   online = false
  93.  end
  94.  if not fs.exists(name) then
  95.   file=fs.open(name,"w")
  96.   last=1
  97.   file.writeLine(last)
  98.   file.close()
  99.  end
  100.  if online == true then
  101.   file=fs.open(name,"w")
  102.   last=0
  103.   file.writeLine(last)
  104.   file.close()
  105.  end
  106.  if online == false then
  107.   file=fs.open(name,"r")
  108.   last=file.readLine()
  109.   file.close()
  110.   last=last+1
  111.   file=fs.open(name,"w")
  112.   file.writeLine(last)
  113.   file.close()
  114.   seconds=last
  115.   minutes=0
  116.   hours=0
  117.   days=0
  118.   while seconds > 60 do
  119.    minutes=minutes+1
  120.    seconds=seconds-60
  121.   end
  122.   while minutes > 60 do
  123.    hours=hours+1
  124.    minutes=minutes-60
  125.   end
  126.   while hours > 24 do
  127.    days=days+1
  128.    hours=hours-24
  129.   end
  130.  end
  131.  if online == true then
  132.   pid=pid+2
  133.   term.setCursorPos( 1,pid )
  134.   print(name)
  135.   term.setCursorPos( 16,pid )
  136.   local w,h = term.getSize()
  137.   for i=16,w do
  138.    write(" ")
  139.   end
  140.   term.setCursorPos( 20,pid )
  141.   print("Online")
  142.   pid=pid-2
  143.  else
  144.   pid=pid+2
  145.   term.setCursorPos( 1,pid )
  146.   print(name)
  147.   term.setCursorPos( 16,pid )
  148.   local w,h = term.getSize()
  149.   for i=16,w do
  150.    write(" ")
  151.   end
  152.   if w < 30 then
  153.    term.setCursorPos( 16,pid )
  154.    if days < 1 then
  155.     print(hours.."h "..minutes.."m "..seconds.."s ago")
  156.    else
  157.     print(days.."d "..hours.."h "..minutes.."m")
  158.    end
  159.   else
  160.    term.setCursorPos( 20,pid )
  161.    print(days.."d "..hours.."h "..minutes.."m "..seconds.."s ago")
  162.   end
  163.   pid=pid-2
  164.  end
  165.  pid=pid+1
  166.  if not fs.exists("player"..pid) then
  167.   pid=1
  168.   print("")
  169.   print("Players: "..pidz)
  170.   file=fs.open("players","w")
  171.   file.writeLine(pidz)
  172.   file.close()
  173.   sleep(0.5)
  174.  end
  175. end
  176. pid=pid-1
Add Comment
Please, Sign In to add comment