Advertisement
endminecraffter

endSecurity

Jun 24th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.92 KB | None | 0 0
  1. --##################--
  2. -- Programm by ecco7777
  3. -- https://pastebin.com/u/ecco7777
  4. -- nicht verändert von endminecraffter
  5. -- https://pastebin.com/u/endminecraffter
  6. -- Server: MyFTB.de Deutsches Minecraft modded Netzwerk
  7. -- Benötigte Mods/Apis: keine
  8. --##################--
  9.  
  10. whitelist="endminecraffter,lidellianerBoss,First28"
  11. blacklist= ""
  12.  
  13.  
  14. side="back"
  15. function wrapPs(peripheralName)
  16. periTab={}
  17. sideTab={}
  18. if peripheralName==nil then
  19. print("Fehler")
  20. end
  21. local peripherals = peripheral.getNames()
  22. local i2 = 1
  23. for i =1, #peripherals do
  24. if peripheral.getType(peripherals[i])==peripheralName then
  25. periTab[i2]=peripheral.wrap(peripherals[i])
  26. sideTab[i2]=peripherals[i]
  27. i2=i2+1
  28. end
  29. end
  30. if periTab~={} then
  31. return periTab,sideTab
  32. else
  33. return nil
  34. end
  35. end
  36.  
  37. function scan(s,mode)
  38. if mode==nil then
  39. mode="all"
  40. end
  41.  
  42. if mode=="mob" or mode=="all" then
  43. mobs=s.getEntityIds("mob")
  44. for i=1, #mobs do
  45. data=nil
  46. data=s.getEntityData(mobs[i],"mob")
  47. if data~=nil then
  48. entity.mob[#entity.mob+1]=data.all()
  49. else
  50. entity.mob[#entity.mob+1]="lost"
  51. end
  52. end
  53. end
  54.  
  55. if mode=="item" or mode=="all" then
  56. items=s.getEntityIds("item")
  57. for i=1, #items do
  58. data=nil
  59. data=s.getEntityData(items[i],"item")
  60. if data~=nil then
  61. entity.item[#entity.item+1]=data.all()
  62. else
  63. entity.item[#entity.item+1]="lost"
  64. end
  65. end
  66. end
  67.  
  68. if mode=="player" or mode=="all" then
  69. players=s.getPlayers()
  70. for i=1, #players do
  71. data=nil
  72. data=s.getPlayerByName(players[i].name)
  73. if data~=nil then
  74. entity.player[#entity.player+1]=data.all()
  75. inv=entity.player[#entity.player].player.inventory
  76. for i2=1, 40 do
  77. if inv[i2]~=nil then
  78. fp=fs.open("temp","w")
  79. itemp=#entity.player
  80. i2temp=i2
  81. error=true
  82. fp.write("entity.player[itemp].player.inventory[i2temp]=inv[i2temp].all() error=false")
  83. fp.close()
  84. shell.run("temp")
  85. shell.run("rm temp")
  86. if error then
  87. entity.player[itemp].player.inventory[i2temp]=nil
  88. end
  89. end
  90. end
  91. else
  92. entity.player[#entity.player+1]="lost"
  93. end
  94. end
  95. end
  96.  
  97. if mode=="minecart" or mode=="all" then
  98. minecarts=s.getEntityIds("minecart")
  99. for i=1, #minecarts do
  100. data=nil
  101. data=s.getEntityData(minecarts[i],"minecart")
  102. if data~=nil then
  103. entity.minecart[#entity.minecart+1]=data.all()
  104. else
  105. entity.minecart[#entity.minecart+1]="lost"
  106. end
  107. end
  108. end
  109.  
  110. if mode=="frame" or mode=="all" then
  111. itemFrames=s.getEntityIds("item_frame")
  112. for i=1, #itemFrames do
  113. data=nil
  114. data=s.getEntityData(itemFrames[i],"item_frame")
  115. if data~=nil then
  116. entity.itemFrame[#entity.itemFrame+1]=data.all()
  117. else
  118. entity.itemFrame[#entity.itemFrame+1]="lost"
  119. end
  120. end
  121. end
  122.  
  123. return entity
  124. end
  125.  
  126. function string.cut(txt,char)
  127. while string.find(txt,char) do
  128. txt=string.sub(txt,1,string.find(txt,char)-1)..string.sub(txt,string.find(txt,char)+1,#txt)
  129. end
  130. return txt
  131. end
  132.  
  133.  
  134. function format(txt)
  135. txt=string.cut(txt,'\n')
  136. txt=string.cut(txt,'\r')
  137. txt=string.cut(txt,'\t')
  138. txt=string.cut(txt," ")
  139. txt=string.sub(txt,1,4000)
  140. return txt
  141. end
  142.  
  143. function scanAll(mode)
  144.     s=wrapPs("openperipheral_sensor")
  145.     entity={}
  146.     entity.item={}
  147.     entity.mob={}
  148.     entity.player={}
  149.     entity.minecart={}
  150.     entity.itemFrame={}
  151.         for i42=1,#s do
  152.             scan(s[i42],mode)
  153.  
  154.             term.clear()
  155.             term.setCursorPos(1,1)
  156.             term.write(math.floor(100/#s*i42).."%")
  157.         end
  158. end
  159.  
  160.  
  161.  
  162. while true do
  163. ownerOnline=false
  164. intruderOnline=false
  165. scanAll("player")
  166.     for i=1,#entity.player do
  167.         if string.find(whitelist,entity.player[i].name)~=nil then
  168.             ownerOnline=true
  169.         end
  170.        
  171.         if string.find(whitelist,entity.player[i].name)==nil and string.find(blacklist,entity.player[i].name)~=nil or #blacklist==0 and  string.find(whitelist,entity.player[i].name)==nil then
  172.             intruderOnline=true
  173.         end
  174.     end
  175.         if ownerOnline==false and intruderOnline then
  176.         rs.setOutput(side,true)
  177.         else
  178.         rs.setOutput(side,false)
  179.         end
  180.         sleep(1)
  181. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement