Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local event = require("event")
- local com = require("component")
- local term = require("term")
- local computer = require("computer")
- local gpu = com.gpu
- local PlayersIDs = {}
- local Players = {}
- local TimePlayer = {}
- local whileList = { -- вот сюда вписываешь ники, которые не будут учитываться.
- "lokin135"
- }
- local ResX, ResY = 0
- local TimeUpdate = 60*3 -- таймер. через 3 минуты будет сново учитывать игрока
- local function PlayerInList(player)
- for i=1,#whileList do
- if player == whileList[i] then
- return true
- end
- end
- return false
- end
- local function updatePlayerCout(nick)
- Players[nick] = Players[nick] + 1
- end
- local function addPlayerToTable(nick)
- TimePlayer[nick] = computer.uptime()
- PlayersIDs[#PlayersIDs+1] = nick
- Players[nick] = 1
- end
- local function detect()
- local _, _, _, _, _, Player = event.pull("motion")
- return Player
- end
- local function drawPlayers()
- for i=1, #PlayersIDs do
- gpu.fill(1,i,ResX,1, " ")
- gpu.set(1,i,PlayersIDs[i].." x"..Players[PlayersIDs[i]])
- end
- end
- local function init()
- term.clear()
- ResX, ResY = gpu.getResolution()
- end
- local function main()
- while true do
- local detectedPlayer = detect()
- if not PlayerInList(detectedPlayer) then
- if Players[detectedPlayer] == nil then
- addPlayerToTable(detectedPlayer)
- else
- if computer.uptime() - TimePlayer[detectedPlayer] > TimeUpdate then
- updatePlayerCout(detectedPlayer)
- TimePlayer[detectedPlayer] = computer.uptime()
- end
- end
- drawPlayers()
- end
- end
- end
- init()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement