Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- scanner = peripheral.wrap("right")
- timeInterval = 1
- logOutputFile = "playerLog"
- newLogTitle = "----Visitors----"
- time = {m = -timeInterval, h = 0, d = 0}
- while true do
- players = scanner.getPlayers()
- time.m = time.m + timeInterval
- if time.m >= 60 then
- time.m = time.m - 60
- time.h = time.h + 1
- if players[1] == nil then logger("Nobody is here.", false) end
- end
- if time.h >= 24 then time.h = time.h - 24 time.d = time.d + 1 end
- function logger(input, title)
- logFile = fs.open(logOutputFile,"a")
- log = input
- if title == false then
- log = "[" .. tostring(time.m) .. "/" .. tostring(time.h) .. "/" .. tostring(time.d) .. "] " .. input
- end
- print(log)
- logFile.writeLine(log)
- logFile.close()
- end
- if time.m == 0 and time.h == 0 and time.d == 0 then logger("\n" .. newLogTitle, true) end
- for i=1,#players do
- for key,value in pairs(players[i]) do
- if key == "name" and value ~= nil then
- logger(value, false)
- end
- end
- end
- sleep(timeInterval * 60)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement