Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("top")
- Turt = 37
- function checkNumber()
- if fs.exists("acc/"..CN..".acc") then
- print("Card Exists")
- C1 = math.random(10000000000,9999999999)
- C2 = math.random(100000,999999)
- CN = C1..C2
- checkNumber()
- else
- print("Generating Card")
- rednet.send(id, CN)
- end
- end
- print("Waiting For Request")
- id, C = rednet.receive()
- if C == "CrdChk" then
- id, Card = rednet.receive()
- print("Receive Card Number")
- id, Pass = rednet.receive()
- print("Received Pin")
- if fs.exists("acc/"..Card..".acc") then
- print("Card Number Exists")
- ca = fs.open("acc/"..Card..".acc", "r")
- Pas = ca.readLine()
- Bal = ca.readLine()
- ca.close()
- if Pas == Pass then
- print("Card Accepted")
- rednet.send(id, "True")
- print("Balance: "..Bal)
- rednet.send(id, Bal)
- shell.run("startup")
- else
- print("Invalid PIN")
- rednet.send(id, "False")
- shell.run("startup")
- end
- else
- print("Card Is Fake")
- rednet.send(id, "False")
- shell.run("startup")
- end
- elseif C == "CPIN" then
- id, ACC = rednet.receive()
- id, NPIN = rednet.receive()
- cp = fs.open("acc/"..ACC..".acc", "r")
- pa = cp.readLine()
- ba = cp.readLine()
- fl = cp.readLine()
- if fl == nil then
- fl = " "
- end
- cp.close()
- np = fs.open("acc/"..ACC..".acc", "w")
- np.writeLine(NPIN)
- np.writeLine(ba)
- np.writeLine(fl)
- np.close()
- shell.run("startup")
- elseif C == "PINCheck" then
- id, ACC = rednet.receive()
- id, PIN = rednet.receive()
- re = fs.open("acc/"..ACC..".acc", "r")
- CPIN = re.readLine()
- re.close()
- if CPIN == PIN then
- rednet.send(id, "true")
- print("Received VALID PIN")
- else
- rednet.send(id, "false")
- end
- shell.run("startup")
- elseif C == "Dpst" then
- print("Waiting For Deposit Amount")
- id, Am = rednet.receive()
- cad = fs.open("acc/"..Card..".acc", "r")
- p = cad.readLine()
- b = cad.readLine()
- A = tonumber(b) + tonumber(Am)
- cad.close()
- print(A)
- ba = fs.open("acc/"..Card..".acc", "w")
- ba.write(p.."\n"..A)
- ba.close()
- shell.run("startup")
- elseif C == "WTrue" then
- id, wam = rednet.receive()
- id, ATMID = rednet.receive()
- print("Withdrawing D$"..wam)
- A = tonumber(Bal) - tonumber(wam)
- if A < 0 then
- rednet.send(id, "Neg")
- rednet.send(ATMID, "False")
- --shell.run("startup")
- else
- rednet.send(id, "Pos")
- rednet.send(ATMID, "True")
- --shell.run("startup")
- ad = fs.open("acc/"..Card..".acc", "r")
- p = ad.readLine()
- ad.close()
- ads = fs.open("acc/"..Card..".acc", "w")
- ads.write(p.."\n"..A)
- ads.close()
- end
- shell.run("startup")
- elseif C == "CA" then
- id, Dp = rednet.receive()
- id, PIN = rednet.receive()
- id, Name = rednet.receive()
- C1 = math.random(100000,999999)
- C2 = math.random(100000,999999)
- CN = "4342"..C1..C2
- checkNumber()
- Cra = fs.open("acc/"..CN..".acc", "w")
- Cra.write(PIN.."\n"..Dp.."\n"..Name)
- Cra.close()
- os.reboot()
- elseif C == "TrmChk" then
- id, User = rednet.receive()
- id, Pass = rednet.receive()
- if fs.exists("acc/"..User..".trm") then
- rf = fs.open("acc/"..User..".trm", "r")
- P = rf.readLine()
- rf.close()
- if P == Pass then
- rednet.send(id, "True")
- shell.run("startup")
- else
- rednet.send(id, "False")
- shell.run("startup")
- end
- else
- rednet.send(id, "False")
- shell.run("startup")
- end
- elseif C == "RA" then
- id, Card = rednet.receive()
- id, PIN = rednet.receive()
- if fs.exists("acc/"..Card..".acc") then
- ra = fs.open("acc/"..Card..".acc", "r")
- PI = ra.readLine()
- ra.close()
- if PIN == PI then
- shell.run("rm", "acc/"..Card..".acc")
- rednet.send(id, "RT")
- shell.run("startup")
- else
- rednet.send(id, "RF")
- shell.run("startup")
- end
- else
- rednet.send(id, "FA")
- shell.run("startup")
- end
- elseif C == "AD" then
- id, Card = rednet.receive()
- id, Am = rednet.receive()
- if fs.exists("acc/"..Card..".acc") then
- de = fs.open("acc/"..Card..".acc", "r")
- PIN = de.readLine()
- Bal = de.readLine()
- de.close()
- Bal = tonumber(Bal)
- Am = tonumber(Am)
- NBal = Bal + Am
- da = fs.open("acc/"..Card..".acc", "w")
- da.write(PIN.."\n"..NBal)
- da.close()
- rednet.send(id, "DT")
- print("Deposited D$"..Am.." to Account#"..Card)
- shell.run("startup")
- else
- rednet.send(id, "DF")
- print("Invalid Account Received")
- shell.run("startup")
- end
- elseif C == "AW" then
- id, Card = rednet.receive()
- id, PIN = rednet.receive()
- id, Am = rednet.receive()
- Am = tonumber(Am)
- if fs.exists("acc/"..Card..".acc") then
- p = fs.open("acc/"..Card..".acc", "r")
- PI = p.readLine()
- Bal = p.readLine()
- p.close()
- Bal = tonumber(Bal)
- if Am > Bal then
- rednet.send(id, "NB")
- shell.run("startup")
- else
- rednet.send(id, "WiT")
- rednet.send(Turt, Am)
- NBal = Bal - Am
- re = fs.open("acc/"..Card..".acc", "w")
- re.write(PI.."\n"..NBal)
- re.close()
- shell.run("startup")
- end
- else
- rednet.send(id, "FA")
- shell.run("startup")
- end
- elseif C == "ChkBal" then
- id, Card = rednet.receive()
- if Card == nil then
- print("System Crash nil Received")
- shell.run("startup")
- elseif fs.exists("acc/"..Card..".acc") then
- Ba = fs.open("acc/"..Card..".acc", "r")
- PI = Ba.readLine()
- Bal = Ba.readLine()
- Ba.close()
- rednet.send(id, Bal)
- shell.run("startup")
- else
- rednet.send(id, "BalF")
- shell.run("startup")
- end
- elseif C == "TrmCrt" then
- id, User = rednet.receive()
- id, Pass = rednet.receive()
- f = fs.open("acc/"..User..".trm", "w")
- f.write(Pass)
- f.close()
- os.reboot()
- elseif C == "TrmDel" then
- id, User = rednet.receive()
- fs.delete("acc/"..User..".trm")
- os.reboot()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement