Advertisement
Guest User

startup

a guest
Mar 23rd, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.59 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.    CN = math.random(10000000000,9999999999)
  7.    checkNumber()
  8.  else
  9.    print("Generating Card")
  10.    rednet.send(id, CN)
  11.  end
  12. end
  13.  
  14. print("Waiting For Request")
  15. id, C = rednet.receive()
  16.  
  17.  
  18. if C == "CrdChk" then
  19.   id, Card = rednet.receive()
  20.   print("Receive Card Number")
  21.   id, Pass = rednet.receive()
  22.   print("Received Pin")
  23.   if fs.exists("acc/"..Card..".acc") then
  24.     print("Card Number Exists")
  25.     ca = fs.open("acc/"..Card..".acc", "r")
  26.     Pas = ca.readLine()
  27.     Bal = ca.readLine()
  28.     ca.close()
  29.     if Pas == Pass then
  30.       print("Card Accepted")
  31.       rednet.send(id, "True")
  32.       print("Balance: "..Bal)
  33.       rednet.send(id, Bal)
  34.       shell.run("startup")
  35.     else
  36.       print("Invalid PIN")
  37.       rednet.send(id, "False")
  38.       shell.run("startup")
  39.     end
  40.   else
  41.     print("Card Is Fake")
  42.     rednet.send(id, "False")
  43.     shell.run("startup")
  44.   end
  45. elseif C == "Dpst" then
  46.   print("Waiting For Deposit Amount")
  47.   id, Am = rednet.receive()
  48.   cad = fs.open("acc/"..Card..".acc", "r")
  49.   p = cad.readLine()
  50.   b = cad.readLine()
  51.   A = tonumber(b) + tonumber(Am)
  52.   cad.close()
  53.   print(A)
  54.   ba = fs.open("acc/"..Card..".acc", "w")
  55.   ba.write(p.."\n"..A)
  56.   ba.close()
  57.   shell.run("startup")    
  58. elseif C == "WTrue" then
  59.   id, wam = rednet.receive()
  60.   id, ATMID = rednet.receive()
  61.   print("Withdrawing D$"..wam)
  62.   A = tonumber(Bal) - tonumber(wam)
  63.   if A < 0 then
  64.     rednet.send(id, "Neg")
  65.     rednet.send(ATMID, "False")
  66.     shell.run("startup")
  67.   else
  68.     rednet.send(id, "Pos")
  69.     rednet.send(ATMID, "True")
  70.     shell.run("startup")
  71.     ad = fs.open("acc/"..Card..".acc", "r")
  72.     p = ad.readLine()
  73.     ad.close()
  74.     ads = fs.open("acc/"..Card..".acc", "w")
  75.     ads.write(p.."\n"..A)
  76.     ads.close()
  77.   end
  78. elseif C == "CA" then
  79.   id, Dp = rednet.receive()
  80.   id, PIN = rednet.receive()
  81.   CN = math.random(1000000000,9999999999)
  82.   checkNumber()
  83.   Cra = fs.open("acc/"..CN..".acc", "w")
  84.   Cra.write(PIN.."\n"..Dp)
  85.   Cra.close()
  86.   os.reboot()
  87. elseif C == "TrmChk" then
  88.   id, User = rednet.receive()
  89.   id, Pass = rednet.receive()
  90.   if fs.exists("acc/"..User..".trm") then
  91.     rf = fs.open("acc/"..User..".trm", "r")
  92.     P = rf.readLine()
  93.     rf.close()
  94.     if P == Pass then
  95.       rednet.send(id, "True")
  96.       shell.run("startup")
  97.     else
  98.       rednet.send(id, "False")
  99.       shell.run("startup")
  100.     end
  101.   else
  102.     rednet.send(id, "False")
  103.     shell.run("startup")
  104.   end
  105. elseif C == "RA" then
  106.   id, Card = rednet.receive()
  107.   id, PIN = rednet.receive()
  108.   if fs.exists("acc/"..Card..".acc") then
  109.     ra = fs.open("acc/"..Card..".acc", "r")
  110.     PI = ra.readLine()
  111.     ra.close()
  112.     if PIN == PI then
  113.       shell.run("rm", "acc/"..Card..".acc")
  114.       rednet.send(id, "RT")
  115.       shell.run("startup")
  116.     else
  117.       rednet.send(id, "RF")
  118.       shell.run("startup")
  119.     end
  120.   else
  121.     rednet.send(id, "FA")
  122.     shell.run("startup")
  123.   end
  124. elseif C == "AD" then
  125.   id, Card = rednet.receive()
  126.   id, Am = rednet.receive()
  127.   if fs.exists("acc/"..Card..".acc") then
  128.     de = fs.open("acc/"..Card..".acc", "r")
  129.     PIN = de.readLine()
  130.     Bal = de.readLine()
  131.     de.close()
  132.     Bal = tonumber(Bal)
  133.     Am = tonumber(Am)
  134.     NBal = Bal + Am
  135.     da = fs.open("acc/"..Card..".acc", "w")
  136.     da.write(PIN.."\n"..NBal)
  137.     da.close()
  138.     rednet.send(id, "DT")
  139.     print("Deposited D$"..Am.." to Account#"..Card)
  140.     shell.run("startup")
  141.   else
  142.     rednet.send(id, "DF")
  143.     print("Invalid Account Received")
  144.     shell.run("startup")
  145.   end
  146. elseif C == "AW" then
  147.   id, Card = rednet.receive()
  148.   id, PIN = rednet.receive()
  149.   id, Am = rednet.receive()
  150.   Am = tonumber(Am)
  151.   if fs.exists("acc/"..Card..".acc") then
  152.     p = fs.open("acc/"..Card..".acc", "r")
  153.     PI = p.readLine()
  154.     Bal = p.readLine()
  155.     p.close()
  156.     Bal = tonumber(Bal)
  157.     if Am > Bal then
  158.       rednet.send(id, "NB")
  159.       shell.run("startup")
  160.     else
  161.     rednet.send(id, "WiT")
  162.     rednet.send(Turt, Am)
  163.     NBal = Bal + Am
  164.     re = fs.open("acc/"..Card..".acc", "w")
  165.     re.write(PI.."\n"..NBal)
  166.     re.close()
  167.     shell.run("startup")
  168.     end
  169.   else
  170.     rednet.send(id, "FA")
  171.     shell.run("startup")
  172.   end
  173. elseif C == "ChkBal" then
  174.   id, Card = rednet.receive()
  175.   if fs.exists("acc/"..Card..".acc") then
  176.     Ba = fs.open("acc/"..Card..".acc", "r")
  177.     PI = Ba.readLine()
  178.     Bal = Ba.readLine()
  179.     Ba.close()
  180.     rednet.send(id, Bal)
  181.     shell.run("startup")
  182.   else
  183.     rednet.send(id, "BalF")
  184.     shell.run("startup")
  185.   end
  186. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement