Advertisement
MrDionesalvi

EPCO Endor

Nov 29th, 2020 (edited)
3,560
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.89 KB | None | 0 0
  1. local maxw, maxh = term.getSize()
  2.  
  3. lato = "bottom"
  4.  
  5. soldi = 2000
  6.  
  7. api1 = "efKZbEf4GJJD"
  8.  
  9. rs.setOutput(lato, true)
  10.  
  11.  
  12.  
  13. -- IMPLEMENTAZIONE DEL DRAWFILLEDBOX
  14. local function drawPixelInternal(xPos, yPos)
  15.     term.setCursorPos(xPos, yPos)
  16.     term.write(" ")
  17. end
  18.  
  19. local tColourLookup = {}
  20. for n = 1, 16 do
  21.     tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
  22. end
  23.  
  24. function drawFilledBox(startX, startY, endX, endY, nColour)
  25.     if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~=
  26.         "number" or type(endY) ~= "number" or
  27.         (nColour ~= nil and type(nColour) ~= "number") then
  28.         error("Expected startX, startY, endX, endY, colour", 2)
  29.     end
  30.  
  31.     startX = math.floor(startX)
  32.     startY = math.floor(startY)
  33.     endX = math.floor(endX)
  34.     endY = math.floor(endY)
  35.  
  36.     if nColour then term.setBackgroundColor(nColour) end
  37.     if startX == endX and startY == endY then
  38.         drawPixelInternal(startX, startY)
  39.         return
  40.     end
  41.  
  42.     local minX = math.min(startX, endX)
  43.     if minX == startX then
  44.         minY = startY
  45.         maxX = endX
  46.         maxY = endY
  47.     else
  48.         minY = endY
  49.         maxX = startX
  50.         maxY = startY
  51.     end
  52.  
  53.     for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end
  54. end
  55.  
  56. function colore(nome) term.setTextColor(nome) end
  57.  
  58. function sfondo(nome) term.setBackgroundColor(nome) end
  59.  
  60. function fineColore() term.setTextColour(colours.white) end
  61.  
  62. function fineSfondo() term.setBackgroundColour(colours.black) end
  63.  
  64. function titolo(testo)
  65.     drawFilledBox(1, 1, maxw, 1, colors.blue)
  66.     term.setCursorPos((maxw - #testo) / 2, 1)
  67.     colore(colors.white)
  68.     term.write(testo)
  69.     sfondo(colors.white)
  70. end
  71.  
  72. function clear()
  73.     sfondo(colors.blue)
  74.     term.clear()
  75.     term.setCursorPos(1, 1)
  76. end
  77.  
  78. function errore(errore)
  79.     sfondo(colors.red)
  80.     colore(colors.white)
  81.     term.clear()
  82.     term.setCursorPos(1, 1)
  83.     titolo("Errore irreversibile")
  84.     term.setCursorPos(1, 3)
  85.     sfondo(colors.red)
  86.     colore(colors.white)
  87.     term.setCursorPos(16, 10)
  88.     term.write("Sei un poraccio...")
  89.     os.sleep(5)
  90.     os.reboot()
  91. end
  92.  
  93. clear()
  94. sfondo(colors.lightBlue)
  95. colore(colors.black)
  96. term.setCursorPos(1, 1)
  97. titolo("Pagamento ENDOR")
  98. term.setCursorPos(1, 3)
  99.  
  100.  
  101. drawFilledBox(16, 9, 33, 11, colors.white)
  102. colore(colors.red)
  103. term.setCursorPos(18, 10)
  104. term.write("Disattiva Endor")
  105.  
  106.  
  107.  
  108. while true do
  109.     local event, par1, par2, par3 = os.pullEvent("mouse_click")
  110.     if par2 >= 20 and par2 <= 27 and par3 >= 10 and par3 <= 12 then -- Utenti
  111.  
  112.         clear()
  113.         term.clear()
  114.         fineSfondo()
  115.         titolo("Login nPay EPCO")
  116.         sfondo(colors.lightBlue)
  117.         colore(colors.white)
  118.         term.setCursorPos(1, 3)
  119.         print("Inserire i propri dati.")
  120.         colore(colors.gray)
  121.         print("\nPremere Enter per confermare i dati inseriti.\nSe i dati sono corretti, il campo diventerà verde.\nSe sono errati, il programma chiederà di reinserirli nuovamente.")
  122.  
  123.         --nomeutente
  124.         term.setCursorPos(1, 10)
  125.         colore(colors.black)
  126.         term.write("Nome utente:")
  127.         term.setCursorPos(15, 10)
  128.         colore(colors.white)
  129.         utenteAccettato = false
  130.         conteggioErrori = 0
  131.         while utenteAccettato == false do
  132.             utente = read()
  133.             checkuser = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=no&richiesta=verifica&utente=" .. utente).readAll()
  134.             tabcheckuser = textutils.unserialize(checkuser)
  135.             if tabcheckuser.stato == "OK" then
  136.                 term.setCursorPos(15, 10)
  137.                 colore(colors.lime)
  138.                 term.write(utente)
  139.                 colore(colors.white)
  140.                 utenteAccettato = true
  141.             else
  142.                 term.setCursorPos(15, 10)
  143.                 colore(colors.red)
  144.                 term.write("Utente errato!")
  145.                 sleep(2)
  146.                 term.setCursorPos(15, 10)
  147.                 colore(colors.white)
  148.                 term.write("                       ")
  149.                 term.setCursorPos(15, 10)
  150.                 conteggioErrori = conteggioErrori + 1
  151.                 if conteggioErrori > 2 then
  152.                     term.setCursorPos(15, 10)
  153.                     colore(colors.red)
  154.                     term.write("Tre tentativi di immissione errati.")
  155.                     sleep(2)
  156.                     term.setCursorPos(15, 10)
  157.                     colore(colors.white)
  158.                     term.write("                       ")
  159.                     term.setCursorPos(15, 10)
  160.                     clear()
  161.                     os.reboot()
  162.                 end
  163.             end
  164.         end
  165.  
  166.         --password
  167.         colore(colors.black)
  168.         term.setCursorPos(1,12)
  169.         term.write("Password:")
  170.         term.setCursorPos(15, 12)
  171.          
  172.         conteggioErrori = 0
  173.         passAccettata = false
  174.         while passAccettata == false do
  175.             colore(colors.white)
  176.             password = read("#")
  177.             colore(colors.black)
  178.             checkuser = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=" .. password .. "&richiesta=addebito&valore=0&utente=".. utente).readAll()
  179.             risposta = textutils.unserialize(checkuser)
  180.             if risposta.stato == "OK" then
  181.                 term.setCursorPos(15, 12)
  182.                 colore(colors.lime)
  183.                 term.write("##############")
  184.                 colore(colors.white)
  185.                 passAccettata = true
  186.                 else
  187.                     term.setCursorPos(15, 12)
  188.                     colore(colors.red)
  189.                     term.write("Password errata!")
  190.                     conteggioErrori = conteggioErrori + 1
  191.                     sleep(2)
  192.                     term.setCursorPos(15, 12)
  193.                     term.write("                       ")
  194.                     term.setCursorPos(15, 12)
  195.                 if conteggioErrori > 2 then
  196.                     term.setCursorPos(15, 12)
  197.                     colore(colors.red)
  198.                     term.write("Tre tentativi di immissione errati.")
  199.                     sleep(2)
  200.                     term.setCursorPos(15, 12)
  201.                     term.write("                       ")
  202.                     term.setCursorPos(15, 12)
  203.                     clear()
  204.                     os.reboot()
  205.                 end
  206.             end
  207.         end
  208.        
  209.         while true do
  210.  
  211.             --Ricontrolla il saldo per gestire l'aggiornamento di piåA5B9 operazioni
  212.             checkuser = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth="..password.."&richiesta=addebito&valore=0&utente="..utente).readAll()
  213.             risposta = textutils.unserialize(checkuser)
  214.             saldo = tonumber(risposta.saldo)
  215.             --Disegna la finestra del pannello utente
  216.             clear()
  217.             titolo("Pannello utente nPay")
  218.             sfondo(colors.lightBlue)
  219.             colore(colors.black)
  220.             term.setCursorPos(1, 3)
  221.             term.write("Benvenuto, ")
  222.             colore(colors.white)
  223.             term.write(utente)
  224.             colore(colors.black)
  225.             term.write("!         Saldo: ")
  226.             colore(colors.white)
  227.             term.write(saldo)
  228.             colore(colors.black)
  229.             term.write(" IC")
  230.             print("\n\nOperazioni disponibili:\n")
  231.             sfondo(colors.lightBlue)
  232.             colore(colors.white)
  233.             print(" Paga 2000IC per Endor  \n")
  234.             colore(colors.red)
  235.             print(" Disconnettiti da RICH  \n")
  236.             colore(colors.black)
  237.  
  238.             antitonto = os.startTimer(60)
  239.  
  240.             event, key, x, y = os.pullEventRaw()
  241.             if event == "mouse_click" and y == 7 and x <= 24 then       --Pulsante carica denaro su nPay
  242.                 clear()
  243.                 titolo("Apertura porta RICH")
  244.                 if(saldo>=soldi) then
  245.                     inviaDenaro = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=" .. password .. "&utente=" .. utente .. "&richiesta=trasferimento&valore=" .. "200" .. "&beneficiario=" .. "calafricagroup").readAll()
  246.                     inviaDenaro = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=" .. password .. "&utente=" .. utente .. "&richiesta=trasferimento&valore=" .. "1800" .. "&beneficiario=" .. "lay4play").readAll()
  247.                     email = http.get("http://t2.narshaddaa.a-centauri.com:8080/alert?key=" .. api1  .. "&thief=" .. utente .. "&info=EPCO%20Ha%20disattivato%20Endor").readAll()
  248.                     risultatoInvio = textutils.unserialize(inviaDenaro)
  249.                     if risultatoInvio.stato == "OK" then
  250.                         term.setCursorPos(1, 10)
  251.                         colore(colors.red)
  252.                         rs.setOutput(lato, false)
  253.                         print("Soldi scalati")
  254.                         print("Corri prima che sia tardi ;)")
  255.                         rs.setOutput("right", true)
  256.                         sleep(0.5)
  257.                         rs.setOutput("right", false)
  258.                         sleep(2)
  259.                         rs.setOutput(lato, true)
  260.                         sleep(180)
  261.                         rs.setOutput("right", true)
  262.                         sleep(0.5)
  263.                         rs.setOutput("right", false)
  264.                         os.reboot()
  265.                     else
  266.                         term.setCursorPos(1, 10)
  267.                         colore(colors.red)
  268.                         term.write("Che culo :(")
  269.                     end
  270.                     sleep(1)
  271.                    
  272.  
  273.                 else
  274.                     errore("poraccio")
  275.                 end
  276.  
  277.             else if event == "mouse_click" and y == 10 and x <= 31 then
  278.                 os.sleep(1)
  279.                 os.reboot()
  280.  
  281.             end
  282.  
  283.             end
  284.  
  285.  
  286.         end
  287.  
  288.     end
  289.  
  290. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement