Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("ldb")
- sensor = peripheral.wrap("top")
- chat = peripheral.wrap("bottom")
- speaker = peripheral.wrap("left")
- ant = peripheral.wrap("back")
- tmr = peripheral.wrap("right")
- gd = 200
- me = "kovakovi2000"
- prefix = "[CUBE] "
- players = sensor.getNearbyPlayers(gd)
- w_near = {}
- w_close = {}
- w_inside = {}
- helmet = ant.getPlayers()
- con = false
- xme = 0
- for i = 1, table.getn(helmet) do
- if helmet[i] == me then
- xme = i
- con = true
- end
- end
- function dtf(str)
- return string.format("%.2d",str)
- end
- function formatTime(v_time)
- return v_time.year .. "." ..
- dtf(v_time.month) .. "." ..
- dtf(v_time.day) .. " " ..
- dtf(v_time.hour) .. ":" ..
- dtf(v_time.minute) .. ":" ..
- dtf(v_time.second)
- end
- if con then
- ame = ant.getHUD(helmet[xme])
- white = ame.getColorFromRGB(255,255,255,255)
- red = ame.getColorFromRGB(255,0,0,255)
- yellow = ame.getColorFromRGB(255,255,0,255)
- green = ame.getColorFromRGB(0,255,0,255)
- function dws(str,ly,color)
- ame.drawString(str,100,ly,color)
- end
- function createHUD()
- ame.drawString(prefix,100,12,white)
- ame.drawHorizontalLine(100,24,200,white)
- end
- if ldb.is("washere") == true then
- ldb.del("washere")
- ame.clear()
- ame.drawString(prefix,300,12,red)
- ame.drawHorizontalLine(300,24,400,red)
- local y = 26
- ls = ldb.list()
- for i = 1, table.getn(ls) do
- if string.find(ls[i], "was_") ~= nil then
- tmp = ldb.get(ls[i])
- ame.drawString(tmp.l_player .. " " .. tmp.l_sdis .. " " .. formatTime(tmp.l_tmr),300,y,red)
- y = y + 12
- ldb.del(ls[i])
- end
- end
- ame.sync()
- sleep(120)
- end
- ame.clear()
- createHUD()
- ame.sync()
- local y = 0
- local tm = 0
- while true do
- createHUD()
- ame.sync()
- sleep(0.1)
- y = 26
- tm = tm + 1
- players = sensor.getNearbyPlayers(gd)
- me_online = false
- for i = 1, table.getn(players) do
- if players[i].player ~= me then
- local dis = players[i].distance
- local sdis = string.format("%2.2f",dis)
- if dis < 10.0 then
- dws(players[i].player .. " " .. sdis, y, red)
- y = y + 12
- if(tm > 20) then
- chat.tell(players[i].player , prefix .. "YOU HAVE NO PERMISSON TO BE HERE, MY MASTER WILL KNOW IT!")
- speaker.speak("YOU HAVE NO PERMISSON TO BE HERE, MY MASTER WILL KNOW IT!", 10)
- tm = 0
- end
- elseif 10.0 < dis and dis < 20.0 then
- dws(players[i].player .. " " .. sdis, y, yellow)
- y = y + 12
- elseif 20.0 < dis and dis < 30.0 then
- dws(players[i].player .. " " .. sdis, y, green)
- y = y + 12
- elseif 30.0 < dis then
- dws(players[i].player .. " " .. sdis, y, white)
- y = y +12
- end
- else
- me_online = true
- end
- end
- if me_online ~= true then
- os.reboot()
- end
- end
- else
- while true do
- sleep(0.1)
- players = sensor.getNearbyPlayers(gd)
- for i = 1, table.getn(players) do
- local dis = players[i].distance
- local sdis = string.format("%2.2f",dis)
- if dis < 10.0 then
- ldb.set("washere", 1)
- ldb.set("was_" .. tmr.getTime(), {l_player = players[i].player, l_sdis = sdis, l_tmr = tmr.getDate()})
- chat.tell(players[i].player , prefix .. "YOU HAVE NO PERMISSON TO BE HERE, MY MASTER WILL KNOW IT!")
- speaker.speak("YOU HAVE NO PERMISSON TO BE HERE, MY MASTER WILL KNOW IT!", 10)
- sleep(2)
- end
- if(players[i].player == me) then
- os.reboot()
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment