Advertisement
Guest User

Untitled

a guest
Sep 19th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. local event = require("event")
  2. local com = require("component")
  3. local term = require("term")
  4. local computer = require("computer")
  5.  
  6. local gpu = com.gpu
  7.  
  8. local PlayersIDs = {}
  9. local Players = {}
  10. local TimePlayer = {}
  11.  
  12. local whileList = { -- вот сюда вписываешь ники, которые не будут учитываться.
  13. "lokin135"
  14. }
  15.  
  16. local ResX, ResY = 0
  17. local TimeUpdate = 60*3 -- таймер. через 3 минуты будет сново учитывать игрока
  18.  
  19. local function PlayerInList(player)
  20. for i=1,#whileList do
  21. if player == whileList[i] then
  22. return true
  23. end
  24. end
  25. return false
  26. end
  27.  
  28. local function updatePlayerCout(nick)
  29. Players[nick] = Players[nick] + 1
  30. end
  31.  
  32. local function addPlayerToTable(nick)
  33. TimePlayer[nick] = computer.uptime()
  34. PlayersIDs[#PlayersIDs+1] = nick
  35. Players[nick] = 1
  36. end
  37.  
  38. local function detect()
  39. local _, _, _, _, _, Player = event.pull("motion")
  40. return Player
  41. end
  42.  
  43. local function drawPlayers()
  44. for i=1, #PlayersIDs do
  45. gpu.fill(1,i,ResX,1, " ")
  46. gpu.set(1,i,PlayersIDs[i].." x"..Players[PlayersIDs[i]])
  47. end
  48. end
  49.  
  50. local function init()
  51. term.clear()
  52. ResX, ResY = gpu.getResolution()
  53. end
  54.  
  55. local function main()
  56. while true do
  57. local detectedPlayer = detect()
  58. if not PlayerInList(detectedPlayer) then
  59. if Players[detectedPlayer] == nil then
  60. addPlayerToTable(detectedPlayer)
  61. else
  62. if computer.uptime() - TimePlayer[detectedPlayer] > TimeUpdate then
  63. updatePlayerCout(detectedPlayer)
  64. TimePlayer[detectedPlayer] = computer.uptime()
  65. end
  66. end
  67. drawPlayers()
  68. end
  69. end
  70. end
  71.  
  72. init()
  73. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement