Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ami = peripheral.wrap("bottom")
- local commandBlock = peripheral.wrap("top")
- -------------------- Config ----------------------------------------------
- P1 = {x=21,y=70,z=235}
- P2 = {x=18,y=75,z=232}
- SpawnPos = {x=21,y=86,z=237}
- UTC = 3
- Admins = {"AlexCC","1Ridav","cyber01","gravityfolls",4}
- ---------------------------------------------------------------------------
- local function GET(url)
- local l = http.get(url)
- if l then
- local retValue = l.readAll()
- l.close()
- return retValue, true
- else
- return nil, false
- end
- end
- function getWorldTime()
- response, state = GET("http://www.timeapi.org/utc/in+" .. UTC .."+hours")
- return string.sub(response, 1, 10)..'-'..string.sub(response, 12, 19)
- end
- local function sayMsg(msg, userName)
- commandBlock.setCommand("/tell "..userName.." "..msg)
- commandBlock.runCommand()
- end
- function pulse(Side,t)
- rs.setOutput(Side,true)
- sleep(t)
- rs.setOutput(Side,false)
- end
- local function Offense(user_name, type_offense,Time)
- pulse("right",10)
- -- type here the punish:
- end
- function Check(ent)
- x,y,z = ent.getPosition()
- if (x>=P2.x and x<=P1.x) and (z>=P2.z and z<=P1.z) and (y>=P1.y and y<=P2.y) then
- return true
- else
- return false
- end
- end
- function Statistic(user)
- if fs.exists("offenders/" .. user) then
- f = fs.open("offenders/" .. user,"r")
- Read = f.readLine()
- f.close()
- sleep(0.3)
- f = fs.open("offenders/" .. user,"w")
- f.write(tostring(Read + 1))
- f.close()
- else
- f = fs.open("offenders/" .. user,"w")
- f.write(1)
- f.close()
- end
- end
- function Log(user,Time,Type)
- if fs.exists("log") then
- f = fs.open("log","a")
- f.writeLine(user .. " " .. Time .. " " .. Type)
- f.close()
- else
- f = fs.open("log","w")
- f.writeLine(user .. " " .. Time .. " " .. Type)
- f.close()
- end
- end
- function Tp(user,x,y,z)
- commandBlock.setCommand("/tp "..user.." "..x.." "..y.." "..z)
- commandBlock.runCommand()
- end
- while true do
- AMI = {}
- AMI[1],AMI[2] = os.pullEvent()
- if AMI[1] == "player_login" then
- Pl = ami.getPlayerByName(AMI[2])
- ent = Pl.asEntity()
- Find = Check(ent)
- if Find then
- sleep(3)
- Time = getWorldTime()
- sayMsg("Offense, tp to spawn!",AMI[2])
- Tp(AMI[2],SpawnPos.x,SpawnPos.y,SpawnPos.z)
- Statistic(AMI[2])
- Log(AMI[2],Time,"Login into secured area")
- for i=1,Admins[5],1 do
- sayMsg("Warning! " .. Admins[i].. ", in bank offenders!",Admins[i])
- end
- Offense(AMI[2],"Login into secured area",Time)
- end
- sleep(1)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement