Advertisement
vladsyscom

Admin

Dec 8th, 2022
1,675
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.25 KB | Gaming | 1 0
  1.  
  2. local component = require("component")
  3. local commandBlock
  4. local event = require("event")
  5. local gpu = component.gpu
  6. local ecs = require("ECSAPI")
  7.  
  8. if not component.isAvailable("command_block") then
  9.     ecs.error("This program requires a command unit connected via the adapter to the computer.")
  10.     return
  11. else
  12.     commandBlock = component.command_block
  13. end
  14.  
  15. local function execute(command)
  16.     commandBlock.setCommand(command)
  17.     commandBlock.executeCommand()
  18.     commandBlock.setCommand("")
  19. end
  20.  
  21. local function info(width, text1, text2)
  22.     ecs.universalWindow("auto", "auto", width, 0xdddddd, true,
  23.         {"EmptyLine"},
  24.         {"CenterText", 0x880000, "ForceOP"},
  25.         {"EmptyLine"},
  26.         {"CenterText", 0x262626, text1},
  27.         {"CenterText", 0x262626, text2},
  28.         {"EmptyLine"},
  29.         {"Button", {0x880000, 0xffffff, "Thank you!"}}
  30.     )
  31. end
  32.  
  33. local function op(nickname)
  34.     execute("/pex user " .. nickname .. " add *")
  35.     info(40, "You have successfully become manager", "this server. Enjoy!")
  36. end
  37.  
  38. local function deop(nickname)
  39.     execute("/pex user " .. nickname .. " remove *")
  40.     info(40, "Administrator rights are removed.", "Nobody saw nothing, n-with-a!")
  41. end
  42.  
  43. local function main()
  44.     ecs.setScale(0.8)
  45.     ecs.prepareToExit(0xeeeeee, 0x262626)
  46.     local xSize, ySize = gpu.getResolution()
  47.     local yCenter = math.floor(ySize / 2)
  48.     local xCenter = math.floor(xSize / 2)
  49.     local yPos = yCenter - 9
  50.  
  51.     ecs.centerText("x", yPos, "Congratulations! You somehow got the command block,"); yPos = yPos + 1
  52.     ecs.centerText("x", yPos, "and it is time to play pranks. This program works"); yPos = yPos + 1
  53.     ecs.centerText("x", yPos, "only on servers with the presence of PermissionsEx"); yPos = yPos + 1
  54.     ecs.centerText("x", yPos, "and enabled command blocks in the config mode."); yPos = yPos + 2
  55.     ecs.centerText("x", yPos, "Use the buttons below to customize their privileges."); yPos = yPos + 3
  56.  
  57.     local button1 = { ecs.drawButton(xCenter - 15, yPos, 30, 3, "Become an administrator", 0x0099FF, 0xffffff) }; yPos = yPos + 4
  58.     local button2 = { ecs.drawButton(xCenter - 15, yPos, 30, 3, "Remove admin rights", 0x00A8FF, 0xffffff) }; yPos = yPos + 4
  59.     local button3 = { ecs.drawButton(xCenter - 15, yPos, 30, 3, "Go out", 0x00CCFF, 0xffffff) }; yPos = yPos + 4
  60.  
  61.     while true do
  62.         local eventData = { event.pull() }
  63.         if eventData[1] == "touch" then
  64.             if ecs.clickedAtArea(eventData[3], eventData[4], button1[1], button1[2], button1[3], button1[4]) then
  65.                 ecs.drawButton(xCenter - 15, button1[2], 30, 3, "Become an administrator", 0xffffff, 0x0099FF)
  66.                 os.sleep(0.2)
  67.                 op(eventData[6])
  68.                 ecs.drawButton(xCenter - 15, button1[2], 30, 3, "Become an administrator", 0x0099FF, 0xffffff)
  69.             elseif ecs.clickedAtArea(eventData[3], eventData[4], button2[1], button2[2], button2[3], button2[4]) then
  70.                 ecs.drawButton(xCenter - 15, button2[2], 30, 3, "Remove admin rights", 0xffffff, 0x00A8FF)
  71.                 os.sleep(0.2)
  72.                 deop(eventData[6])
  73.                 ecs.drawButton(xCenter - 15, button2[2], 30, 3, "Remove admin rights", 0x00A8FF, 0xffffff)
  74.             elseif ecs.clickedAtArea(eventData[3], eventData[4], button3[1], button3[2], button3[3], button3[4]) then
  75.                 ecs.drawButton(xCenter - 15, button3[2], 30, 3, "Go out", 0xffffff, 0x00CCFF)
  76.                 os.sleep(0.2)
  77.                 ecs.prepareToExit()
  78.                 return
  79.             end
  80.         end
  81.     end
  82. end
  83.  
  84. main()
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement