xXm0dzXx

Untitled

Jul 22nd, 2012
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.39 KB | None | 0 0
  1. local blocked = {}
  2. local antiBLOCKER = {}
  3.  
  4. rednet.open("top")
  5. shell.run("clear")
  6. function cPrint(str, ypos)
  7. w, h = term.getSize()
  8. for i=1,w-1 do
  9. write("-")
  10. end
  11. term.setCursorPos(w/2-#str/2, ypos)
  12. write(str)
  13. end
  14.  
  15. cPrint("ComputerCraft Virtual Bank", 1)
  16. print()
  17. fs.makeDir("Accounts")
  18.  
  19. while true do
  20. id, message = rednet.receive()
  21. local tWords = {}
  22. for match in string.gmatch(message, "[^:\t]+") do
  23. table.insert( tWords, match )
  24. end
  25.  
  26. --Format:
  27. --GIVE:<YOUR NAME>:<YOUR PASS>:<HOW MUCH U WANNA GIVE TO...>:<YOUR FRIEND>
  28. if tWords[1] == "GIVE" then
  29. if tWords[5] then
  30. if fs.exists("Accounts/" ..tWords[2]) then
  31. a = fs.open("Accounts/" ..tWords[2], "r")
  32. --File Format:
  33. --<Pass>
  34. --<Your money>
  35. Password = a.readLine()
  36. YourCurrent = tonumber(a.readLine())
  37. YourPay = tonumber(tWords[4])
  38. a.close()
  39.  
  40. if tWords[3] == Password and fs.exists("Accounts/" ..tWords[5]) then
  41. if YourCurrent > YourPay or YourCurrent == YourPay then
  42. test = fs.open("Accounts/" ..tWords[5], "r")
  43. TheirPass = test.readLine()
  44. TheirCurrency = tonumber(test.readLine())
  45. test.close()
  46.  
  47. if((TheirCurrency + YourPay) < TheirCurrency) or tWords[5] == tWords[2] then
  48. print("Hacker attempt from " ..id)
  49. else
  50. fs.delete("Accounts/" ..tWords[5])
  51.  
  52. test = fs.open("Accounts/" ..tWords[5], "w")
  53. test.writeLine(TheirPass)
  54. test.writeLine(TheirCurrency + YourPay)
  55. YourCurrent = YourCurrent - YourPay
  56. a = fs.open("Accounts/" ..tWords[2], "w")
  57. a.writeLine(tWords[3])
  58. a.writeLine(YourCurrent)
  59. a.close()
  60. test.close()
  61.  
  62. print(tWords[2].. " gave " ..tWords[5].. " $" ..YourPay)
  63. end
  64. else
  65. print("Insignificant funds")
  66. end
  67. else
  68. print("Payment failed. " ..id)
  69. end
  70. else
  71. print("Payment failed. " ..id)
  72. end
  73. else
  74. print("Junk received from " ..id)
  75. end
  76. elseif tWords[1] == "NEW" then --NEW:<UR NAME>:<UR PASS>
  77. if tWords[3] then
  78. if fs.exists("Accounts/" ..tWords[2]) then
  79. print("Register failed. " ..id)
  80. else
  81. test = fs.open("Accounts/" ..tWords[2], "w")
  82. if test then
  83. test.writeLine(tWords[3])
  84. test.writeLine("0") --0 dollars
  85. test.close()
  86. else
  87. print("Register failed... :C")
  88. end
  89.  
  90. print("Register complete!")
  91. end
  92. else
  93. print("Junk received from " ..id)
  94. end
  95. elseif tWords[1] == "VERIFY" then
  96. if tWords[3] then
  97. if fs.exists("Accounts/" ..tWords[2]) then
  98. a = fs.open("Accounts/" ..tWords[2], "r")
  99. Password = a.readLine()
  100. a.close()
  101. if Password == tWords[3] then
  102. rednet.send(id, "Correct")
  103. print(id.. " logged in.")
  104. else
  105. rednet.send(id, "Wrong")
  106. print("Failed #2 (" ..Password.. ")")
  107. end
  108.  
  109. else
  110. rednet.send(id, "Wrong")
  111. print("Failed #1")
  112. end
  113. else
  114. print("Junk received from " ..id)
  115. end
  116. elseif tWords[1] == "CHECK" then --CHECK:<UR NAME> will send you the balance of <UR NAME>
  117. if tWords[2] then
  118. test = fs.open("Accounts/" ..tWords[2], "r")
  119. if test then
  120. test.readLine()
  121. rednet.send(id, test.readLine())
  122. test.close()
  123. print("Checked!")
  124. else
  125. rednet.send(id, "Unknown Username/Pass")
  126. end
  127. else
  128. print("Junk received from " ..id)
  129. end
  130. else
  131. print("Junk received from " ..id)
  132. end
  133. end
Advertisement
Add Comment
Please, Sign In to add comment