Advertisement
Guest User

Untitled

a guest
Jan 16th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.19 KB | None | 0 0
  1. c = require("component")
  2. db = c.debug
  3. local confirm
  4. local answerLoan
  5. local amountLoan
  6. local activeLoan = {}
  7. activeLoan[1]= {"Ralileo16",false,0,0}
  8. activeLoan[2]= {"Wisardhec115",false,0,0}
  9. activeLoan[3]= {"ZachX200",false,0,0}
  10. activeLoan[4]= {"3Sabres",false,0,0}
  11. while true do
  12. term.clear()
  13. output,username = 0,"blank"
  14. local output,username = db.runCommand("testfor @p[x=-609,y=70,z=215,r=5]")
  15. if (output==0) then
  16.   print("Can't find player")
  17.   repeat
  18.     io.write("Press enter to continue...")
  19.     io.flush()
  20.     confirm = io.read()
  21.   until confirm==""
  22.   confirm="blank"
  23.   goto ending
  24. end
  25. local length = string.len(username)
  26. username = string.sub(username,7,length)
  27. local i
  28. if username=="Ralileo16" then i = 1 end
  29. if username=="Wisardhec115" then i = 2 end
  30. if username=="ZachX200" then i = 3 end
  31. if username=="3Sabres" then i = 4 end
  32. repeat
  33.   print("1.Make a loan")
  34.   print("2.Pay a loan")
  35.   print("3.Come back later")
  36.   io.flush()
  37.   answerLoan=io.read()
  38. until answerLoan=="1" or answerLoan=="2" or answerLoan=="3"
  39. if (answerLoan=="1") then
  40. if (activeLoan[i][2]==true) then
  41.   print("Sorry, you already have an active loan please pay the remaining balance before requesting another loan.")
  42.   repeat
  43.     io.write("Press enter to continue...")
  44.     io.flush()
  45.     local confirm = io.read()
  46.   until confirm==""
  47.   confirm="blank"
  48.   goto ending
  49. end
  50.   repeat
  51.     io.write("Please enter the amount you would like to receive.")
  52.     io.flush()
  53.     amountLoan=tonumber(io.read())
  54.   until type(amountLoan)=="number" and amountLoan<=50000 and amountLoan>0
  55.   db.runCommand("give "..username.." enderpay:filled_banknote 1 0 {DateIssued:0L,Amount:"..amountLoan.."L}")
  56.   activeLoan[i][2]=true
  57.   activeLoan[i][3]=amountLoan
  58.   activeLoan[i][4]=math.floor(amountLoan*1.2)
  59.   print("Thanks for using Ralileo16's Bank!\nYou withdrew "..amountLoan.." credits.\nYour total due balance is now "..activeLoan[i][4])
  60.   repeat
  61.     io.write("Press enter to continue...")
  62.     io.flush()
  63.     confirm = io.read()
  64.   until confirm==""
  65.   confirm="blank"
  66. elseif (answerLoan=="2") then
  67.   if (activeLoan[i][2]==false) then
  68.     print("You don't have any active loan")
  69.     repeat
  70.       io.write("Press enter to continue...")
  71.       io.flush()
  72.       local confirm = io.read()
  73.     until confirm==""
  74.     confirm="blank"
  75.     goto ending
  76.   end
  77.   local output,balance = db.runCommand("wallet balance"..username)
  78.   if (output==0) then
  79.     print("Can't find player")
  80.     repeat
  81.       io.write("Press enter to continue...")
  82.       io.flush()
  83.       local confirm = io.read()
  84.     until confirm==""
  85.     confirm="blank"
  86.     goto ending
  87.   end
  88.   if (balance>=activeLoan[i][4]) then
  89.   db.runCommand("wallet take"..username.." "..activeLoan[i][4])
  90.   activeLoan[i]= {username,false,0,0}
  91.   print("You paid your remaining balance! You can now make another loan")
  92.     repeat
  93.     io.write("Press enter to continue...")
  94.     io.flush()
  95.     local confirm = io.read()
  96.   until confirm==""
  97.   confirm="blank"
  98.   goto ending
  99.   end
  100. else
  101.   print("Have a nice day!")
  102.   repeat
  103.     io.write("Press enter to continue...")
  104.     io.flush()
  105.     local confirm = io.read()
  106.   until confirm==""
  107.   confirm="blank"
  108.   goto ending
  109. end
  110. ::ending::
  111. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement