Advertisement
Guest User

startup

a guest
Nov 30th, 2018
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.87 KB | None | 0 0
  1. rednet.open("top")
  2. Turt = 37
  3. function checkNumber()
  4.  if fs.exists("acc/"..CN..".acc") then
  5.    print("Card Exists")
  6.    C1 = math.random(10000000000,9999999999)
  7.    C2 = math.random(100000,999999)
  8.    CN = C1..C2
  9.    checkNumber()
  10.  else
  11.    print("Generating Card")
  12.    rednet.send(id, CN)
  13.  end
  14. end
  15.  
  16. print("Waiting For Request")
  17. id, C = rednet.receive()
  18.  
  19.  
  20. if C == "CrdChk" then
  21.   id, Card = rednet.receive()
  22.   print("Receive Card Number")
  23.   id, Pass = rednet.receive()
  24.   print("Received Pin")
  25.   if fs.exists("acc/"..Card..".acc") then
  26.     print("Card Number Exists")
  27.     ca = fs.open("acc/"..Card..".acc", "r")
  28.     Pas = ca.readLine()
  29.     Bal = ca.readLine()
  30.     ca.close()
  31.     if Pas == Pass then
  32.       print("Card Accepted")
  33.       rednet.send(id, "True")
  34.       print("Balance: "..Bal)
  35.       rednet.send(id, Bal)
  36.       shell.run("startup")
  37.     else
  38.       print("Invalid PIN")
  39.       rednet.send(id, "False")
  40.       shell.run("startup")
  41.     end
  42.   else
  43.     print("Card Is Fake")
  44.     rednet.send(id, "False")
  45.     shell.run("startup")
  46.   end
  47. elseif C == "CPIN" then
  48.   id, ACC = rednet.receive()
  49.   id, NPIN = rednet.receive()
  50.  
  51.   cp = fs.open("acc/"..ACC..".acc", "r")
  52.  
  53.   pa = cp.readLine()
  54.   ba = cp.readLine()
  55.   fl = cp.readLine()
  56.  
  57.   if fl == nil then
  58.     fl = " "
  59.   end
  60.  
  61.   cp.close()
  62.  
  63.   np = fs.open("acc/"..ACC..".acc", "w")
  64.  
  65.   np.writeLine(NPIN)
  66.   np.writeLine(ba)
  67.   np.writeLine(fl)
  68.  
  69.   np.close()
  70.  
  71.   shell.run("startup")
  72. elseif C == "PINCheck" then
  73.   id, ACC = rednet.receive()
  74.   id, PIN = rednet.receive()
  75.  
  76.   re = fs.open("acc/"..ACC..".acc", "r")
  77.   CPIN = re.readLine()
  78.   re.close()
  79.  
  80.   if CPIN == PIN then
  81.     rednet.send(id, "true")
  82.     print("Received VALID PIN")
  83.   else
  84.     rednet.send(id, "false")
  85.   end
  86.  
  87.   shell.run("startup")
  88.  
  89. elseif C == "Dpst" then
  90.   print("Waiting For Deposit Amount")
  91.   id, Am = rednet.receive()
  92.   cad = fs.open("acc/"..Card..".acc", "r")
  93.   p = cad.readLine()
  94.   b = cad.readLine()
  95.   A = tonumber(b) + tonumber(Am)
  96.   cad.close()
  97.   print(A)
  98.   ba = fs.open("acc/"..Card..".acc", "w")
  99.   ba.write(p.."\n"..A)
  100.   ba.close()
  101.   shell.run("startup")    
  102. elseif C == "WTrue" then
  103.   id, wam = rednet.receive()
  104.   id, ATMID = rednet.receive()
  105.   print("Withdrawing D$"..wam)
  106.   A = tonumber(Bal) - tonumber(wam)
  107.   if A < 0 then
  108.     rednet.send(id, "Neg")
  109.     rednet.send(ATMID, "False")
  110.     --shell.run("startup")
  111.   else
  112.     rednet.send(id, "Pos")
  113.     rednet.send(ATMID, "True")
  114.     --shell.run("startup")
  115.     ad = fs.open("acc/"..Card..".acc", "r")
  116.     p = ad.readLine()
  117.     ad.close()
  118.     ads = fs.open("acc/"..Card..".acc", "w")
  119.     ads.write(p.."\n"..A)
  120.     ads.close()
  121.   end
  122.   shell.run("startup")
  123. elseif C == "CA" then
  124.   id, Dp = rednet.receive()
  125.   id, PIN = rednet.receive()
  126.   id, Name = rednet.receive()
  127.   C1 = math.random(100000,999999)
  128.   C2 = math.random(100000,999999)
  129.   CN = "4342"..C1..C2
  130.   checkNumber()
  131.   Cra = fs.open("acc/"..CN..".acc", "w")
  132.   Cra.write(PIN.."\n"..Dp.."\n"..Name)
  133.   Cra.close()
  134.   os.reboot()
  135. elseif C == "TrmChk" then
  136.   id, User = rednet.receive()
  137.   id, Pass = rednet.receive()
  138.   if fs.exists("acc/"..User..".trm") then
  139.     rf = fs.open("acc/"..User..".trm", "r")
  140.     P = rf.readLine()
  141.     rf.close()
  142.     if P == Pass then
  143.       rednet.send(id, "True")
  144.       shell.run("startup")
  145.     else
  146.       rednet.send(id, "False")
  147.       shell.run("startup")
  148.     end
  149.   else
  150.     rednet.send(id, "False")
  151.     shell.run("startup")
  152.   end
  153. elseif C == "RA" then
  154.   id, Card = rednet.receive()
  155.   id, PIN = rednet.receive()
  156.   if fs.exists("acc/"..Card..".acc") then
  157.     ra = fs.open("acc/"..Card..".acc", "r")
  158.     PI = ra.readLine()
  159.     ra.close()
  160.     if PIN == PI then
  161.       shell.run("rm", "acc/"..Card..".acc")
  162.       rednet.send(id, "RT")
  163.       shell.run("startup")
  164.     else
  165.       rednet.send(id, "RF")
  166.       shell.run("startup")
  167.     end
  168.   else
  169.     rednet.send(id, "FA")
  170.     shell.run("startup")
  171.   end
  172. elseif C == "AD" then
  173.   id, Card = rednet.receive()
  174.   id, Am = rednet.receive()
  175.   if fs.exists("acc/"..Card..".acc") then
  176.     de = fs.open("acc/"..Card..".acc", "r")
  177.     PIN = de.readLine()
  178.     Bal = de.readLine()
  179.     de.close()
  180.     Bal = tonumber(Bal)
  181.     Am = tonumber(Am)
  182.     NBal = Bal + Am
  183.     da = fs.open("acc/"..Card..".acc", "w")
  184.     da.write(PIN.."\n"..NBal)
  185.     da.close()
  186.     rednet.send(id, "DT")
  187.     print("Deposited D$"..Am.." to Account#"..Card)
  188.     shell.run("startup")
  189.   else
  190.     rednet.send(id, "DF")
  191.     print("Invalid Account Received")
  192.     shell.run("startup")
  193.   end
  194. elseif C == "AW" then
  195.   id, Card = rednet.receive()
  196.   id, PIN = rednet.receive()
  197.   id, Am = rednet.receive()
  198.   Am = tonumber(Am)
  199.   if fs.exists("acc/"..Card..".acc") then
  200.     p = fs.open("acc/"..Card..".acc", "r")
  201.     PI = p.readLine()
  202.     Bal = p.readLine()
  203.     p.close()
  204.     Bal = tonumber(Bal)
  205.     if Am > Bal then
  206.       rednet.send(id, "NB")
  207.       shell.run("startup")
  208.     else
  209.     rednet.send(id, "WiT")
  210.     rednet.send(Turt, Am)
  211.     NBal = Bal - Am
  212.     re = fs.open("acc/"..Card..".acc", "w")
  213.     re.write(PI.."\n"..NBal)
  214.     re.close()
  215.     shell.run("startup")
  216.     end
  217.   else
  218.     rednet.send(id, "FA")
  219.     shell.run("startup")
  220.   end
  221. elseif C == "ChkBal" then
  222.   id, Card = rednet.receive()
  223.   if Card == nil then
  224.     print("System Crash nil Received")
  225.     shell.run("startup")
  226.   elseif fs.exists("acc/"..Card..".acc") then
  227.     Ba = fs.open("acc/"..Card..".acc", "r")
  228.     PI = Ba.readLine()
  229.     Bal = Ba.readLine()
  230.     Ba.close()
  231.     rednet.send(id, Bal)
  232.     shell.run("startup")
  233.   else
  234.     rednet.send(id, "BalF")
  235.     shell.run("startup")
  236.   end
  237. elseif C == "TrmCrt" then
  238.   id, User = rednet.receive()
  239.   id, Pass = rednet.receive()
  240.   f = fs.open("acc/"..User..".trm", "w")
  241.   f.write(Pass)
  242.   f.close()
  243.   os.reboot()
  244. elseif C == "TrmDel" then
  245.   id, User = rednet.receive()
  246.   fs.delete("acc/"..User..".trm")
  247.   os.reboot()
  248. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement