Advertisement
Guest User

Untitled

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