Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.pullEvent = os.pullEventRaw
- rednet.open("left") --Modem side
- sId = 13 -- ServerId, Run id on your server computer to access
- os.loadAPI("crypt")
- local cbl = peripheral.wrap("top") --Command Block side
- while true do
- shell.run("clear")
- if disk.hasData("bottom") == false then
- while true do
- print("Please insert bank card")
- if os.pullEvent("disk") then
- break
- end
- end
- elseif disk.hasData("bottom") == true then
- local acc = disk.getLabel("bottom")
- shell.run("clear")
- print("Welcome "..acc)
- print("Please enter your P.I.N.:")
- pwd = read("*")
- rednet.send(sId, textutils.serialize({"login", acc, crypt.hashPassword(pwd)}))
- print("pwd sent")
- id,msg = rednet.receive()
- print("reply received")
- local data = textutils.unserialize(msg)
- local cmd = data[1]
- local acc = data[name]
- local bal = data[bal]
- if cmd == "confirm" then
- shell.run("clear")
- print("Password accepted")
- sleep(2)
- while true do
- shell.run("clear")
- local opts = {}
- local opts1 = "Balance Enquiry"
- local opts2 = "Withdraw"
- local opts3 = "Deposit"
- local opts4 = "Transfer"
- print("What would you like to do")
- print("")
- for a,b in ipairs(opts) do
- print(tostring(a)..") "..tostring(b))
- end
- local cmd = read()
- if cmd == 1 or "Balance" or "balance" then
- shell.run("clear")
- print("Balance:")
- print("$"..bal)
- elseif cmd == 2 or "Withdraw" or "withdraw" then
- shell.run("clear")
- write("How much do you want to withdraw: $")
- local amt = read()
- print("Processing")
- sleep(5)
- if amt == bal or amt < bal then
- shell.run("clear")
- print("Confirm withdrawal of $"..amt.." from Acc: "..acc..": $"..bal.."?")
- print("Y/N")
- local cmd = read()
- if cmd == "Y" or "y" then
- rednet.send(sId, textutils.serialize({"withdraw", acc, crypt.hashPassword(pwd), amt}))
- local id, msg = rednet.receive()
- local data = textutils.unserialize(msg)
- if cmd == "confirm" then
- cbl.setCommand("eco give @p amt")
- cbl.runCommand()
- shell.run("clear")
- print("New balance:")
- print("$"..bal)
- sleep(5)
- else
- shell.run("clear")
- print("We were unable to process this transaction please try again")
- sleep(3)
- end
- else
- shell.run("clear")
- print("Withdrawal cancelled")
- sleep(3)
- end
- else
- print("You do not have enough funds to complete this transaction")
- sleep(3)
- end
- elseif cmd == 3 or "Deposit" or "deposit" then
- shell.run("clear")
- write("How much do you want to deposit: $")
- local amt = read()
- print("Processing")
- sleep(5)
- shell.run("clear")
- print("Confirm withdrawal of $"..amt.." from Acc: "..acc..": $"..bal.."?")
- print("Y/N")
- local cmd = read()
- if cmd == "Y" or "y" then
- rednet.send(sId, textutils.serialize({"deposit", acc, crypt.hashPassword(pwd), amt}))
- local id, msg = rednet.receive()
- local data = textutils.unserialize(msg)
- if cmd == "confirm" then
- shell.run("clear")
- print("Deposited $"..amt.." into "..acc.."'s account")
- cbl.setCommand("eco take @p amt")
- cbl.runCommand()
- sleep(3)
- else
- shell.run("clear")
- print("We were unable to process this transaction please try again")
- sleep(3)
- end
- else
- shell.run("clear")
- print("Transaction cancelled")
- sleep(3)
- end
- elseif cmd == 4 or "Transfer" or "transfer" then
- shell.run("clear")
- write("Type the account name you would like to transfer funds to: ")
- local toAcc = read()
- shell.run("clear")
- write("Please enter the amount you wish to transfer: $")
- local amt = read()
- shell.run("clear")
- print("Please confirm, you wish to transfer $"..amt.." from "..acc.." to "..toA.." Y/N")
- local cmd = read()
- shell.run("clear")
- print("Processing")
- sleep(3)
- if cmd == "Y" or "y" then
- if amt == bal or amt < bal then
- rednet.send(sId, textutils.serialize({"transfer", acc, crypt.hashPassword(pwd), amt, toA}))
- local id,msg = rednet.receive()
- local data = textutils.unserialize(msg)
- if cmd == "confirm" then
- shell.run("clear")
- print("$"..amt.." transferred to "..toA)
- sleep(3)
- else
- shell.run("clear")
- print("We were unable to process this transaction please try again")
- sleep(3)
- end
- else
- shell.run("clear")
- print("You do not have enough funds to complete this transaction")
- sleep(3)
- end
- else
- shell.run("clear")
- print("Transaction cancelled")
- sleep(3)
- end
- else
- sleep(10)
- print("Took too long to make a selection, cancelling transaction")
- sleep(3)
- disk.eject("bottom")
- break
- end
- end
- else
- print("Incorrect Password, Try Again")
- sleep(5)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment