Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- c = require("component")
- db = c.debug
- local confirm
- local answerLoan
- local amountLoan
- local activeLoan = {}
- activeLoan[1]= {"Ralileo16",false,0,0}
- activeLoan[2]= {"Wisardhec115",false,0,0}
- activeLoan[3]= {"ZachX200",false,0,0}
- activeLoan[4]= {"3Sabres",false,0,0}
- while true do
- term.clear()
- output,username = 0,"blank"
- local output,username = db.runCommand("testfor @p[x=-609,y=70,z=215,r=5]")
- if (output==0) then
- print("Can't find player")
- repeat
- io.write("Press enter to continue...")
- io.flush()
- confirm = io.read()
- until confirm==""
- confirm="blank"
- goto ending
- end
- local length = string.len(username)
- username = string.sub(username,7,length)
- local i
- if username=="Ralileo16" then i = 1 end
- if username=="Wisardhec115" then i = 2 end
- if username=="ZachX200" then i = 3 end
- if username=="3Sabres" then i = 4 end
- repeat
- print("1.Make a loan")
- print("2.Pay a loan")
- print("3.Come back later")
- io.flush()
- answerLoan=io.read()
- until answerLoan=="1" or answerLoan=="2" or answerLoan=="3"
- if (answerLoan=="1") then
- if (activeLoan[i][2]==true) then
- print("Sorry, you already have an active loan please pay the remaining balance before requesting another loan.")
- repeat
- io.write("Press enter to continue...")
- io.flush()
- local confirm = io.read()
- until confirm==""
- confirm="blank"
- goto ending
- end
- repeat
- io.write("Please enter the amount you would like to receive.")
- io.flush()
- amountLoan=tonumber(io.read())
- until type(amountLoan)=="number" and amountLoan<=50000 and amountLoan>0
- db.runCommand("give "..username.." enderpay:filled_banknote 1 0 {DateIssued:0L,Amount:"..amountLoan.."L}")
- activeLoan[i][2]=true
- activeLoan[i][3]=amountLoan
- activeLoan[i][4]=math.floor(amountLoan*1.2)
- print("Thanks for using Ralileo16's Bank!\nYou withdrew "..amountLoan.." credits.\nYour total due balance is now "..activeLoan[i][4])
- repeat
- io.write("Press enter to continue...")
- io.flush()
- confirm = io.read()
- until confirm==""
- confirm="blank"
- elseif (answerLoan=="2") then
- if (activeLoan[i][2]==false) then
- print("You don't have any active loan")
- repeat
- io.write("Press enter to continue...")
- io.flush()
- local confirm = io.read()
- until confirm==""
- confirm="blank"
- goto ending
- end
- local output,balance = db.runCommand("wallet balance"..username)
- if (output==0) then
- print("Can't find player")
- repeat
- io.write("Press enter to continue...")
- io.flush()
- local confirm = io.read()
- until confirm==""
- confirm="blank"
- goto ending
- end
- if (balance>=activeLoan[i][4]) then
- db.runCommand("wallet take"..username.." "..activeLoan[i][4])
- activeLoan[i]= {username,false,0,0}
- print("You paid your remaining balance! You can now make another loan")
- repeat
- io.write("Press enter to continue...")
- io.flush()
- local confirm = io.read()
- until confirm==""
- confirm="blank"
- goto ending
- end
- else
- print("Have a nice day!")
- repeat
- io.write("Press enter to continue...")
- io.flush()
- local confirm = io.read()
- until confirm==""
- confirm="blank"
- goto ending
- end
- ::ending::
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement