Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fileName = "server"
- if(fs.exists(fileName) == true)then
- print("Installing BlueBank Server System")
- shell.run("rename "..fileName.." startup")
- sleep(5)
- os.reboot()
- end
- --[ Welcome to BlueBank made by TrumpetMiner v3.5
- --[ pastebin get VkYYSbR4 server
- --[ To Setup Your Server, Edit The Following
- -- Authorization Code
- authSet = 3
- function authF()
- authSet = authSet * 2 + 7
- end
- server = nil -- Admin ID#
- function getserver()
- local fname = "ServerID"
- if fs.exists(fname) then
- file = fs.open(fname, "r")
- server = tonumber(file.readAll())
- file.close()
- print("Server ID: "..server)
- else
- print("No server configured")
- print("This ID is: ".. os.getComputerID())
- term.write("Server ID: ")
- server = io.read()
- file = fs.open(fname, "w")
- file.write(server)
- file.close()
- server = tonumber(server)
- end
- end
- getserver()
- -- Determine where the modem is.
- print("Looking for modem,")
- if peripheral.isPresent("left") and peripheral.getType("left")=="modem" then
- side = "left"
- elseif peripheral.isPresent("right") and peripheral.getType("right")=="modem" then
- side = "right"
- elseif peripheral.isPresent("top") and peripheral.getType("top")=="modem" then
- side = "top"
- elseif peripheral.isPresent("back") and peripheral.getType("back")=="modem" then
- side = "back"
- elseif peripheral.isPresent("bottom") and peripheral.getType("bottom")=="modem" then
- side = "bottom"
- else
- print("No Modem Found")
- side = false
- end
- while side == false do
- sleep(5)
- shell.run("startup")
- end
- print("Modem found on "..side)
- rednet.open(side)
- -- Functions
- function drawStart()
- term.clear()
- cur(1,1)
- print ("BlueBank Server 3.0 Status: Online Server ID: " .. tonumber(server))
- print "--------------------------------------"
- cur(3,4)
- print("Current Auth Code > "..authSet)
- id, message = rednet.receive()
- if type(message) == "string" then
- if message == "Login" then
- login()
- elseif message == "Balance" then
- balance()
- elseif message == "Transfer" then
- transfer()
- elseif message == "Create" then
- create()
- elseif message == "Delete" then
- delete()
- elseif message == "Rename" then
- rename()
- elseif message == "Passcode" then
- passcode()
- elseif message == "Add" then
- add()
- elseif message == "Auth" then
- auth()
- else
- rednet.send(id,"Command Not Found")
- drawStart()
- end
- else
- rednet.send(id,"Data is Not String")
- end
- end
- function login()
- id, user = rednet.receive()
- id, pass = rednet.receive()
- if type(pass) == "string" then
- if type(user) == "string" then
- if fs.exists("user/"..user) == true then
- h = fs.open("user/"..user, "r")
- passReal = h.readAll()
- h.close()
- if pass == passReal then
- rednet.send(id,"Login Successful")
- drawStart()
- else
- rednet.send(id,"Password Incorrect")
- drawStart()
- end
- else
- rednet.send(id,"Unknown User")
- drawStart()
- end
- else
- rednet.send(id,"User Is Not String")
- end
- else
- rednet.send(id,"Password Is Not String")
- end
- end
- function balance()
- id, user = rednet.receive()
- if type(user) == "string" then
- h = fs.open("$/"..user, "r")
- bal = h.readAll()
- h.close()
- rednet.send(id,bal)
- drawStart()
- else
- rednet.send(id,"User is Not String")
- end
- end
- function transfer()
- id, user1 = rednet.receive()
- id, user2 = rednet.receive()
- id, am = rednet.receive()
- if type(user1) == "string" and type(user2) == "string" and type(am) == "string" then
- if fs.exists("user/"..user1) and fs.exists("user/"..user2)then
- h = fs.open("$/"..user1, "r")
- bal1 = h.readAll()
- h.close()
- if tonumber(bal1) >= tonumber(am) then
- h = fs.open("$/"..user2, "r")
- bal2 = h.readAll()
- h.close()
- bal1 = bal1 - am
- bal2 = bal2 + am
- h = fs.open("$/"..user1, "w")
- h.write(bal1)
- h.close()
- h = fs.open("$/"..user2, "w")
- h.write(bal2)
- h.close()
- rednet.send(id,"Funds Transfered")
- drawStart()
- elseif bal1 <= am then
- rednet.send(id,"Not Enough Funds")
- --term.setCursorPos(1,3)
- --print(user1)
- --print(user2)
- --print(bal1)
- --print(bal2)
- --print(am)
- drawStart()
- else
- rednet.send(id,"An Error Occurred")
- drawStart()
- end
- else
- rednet.send(id," User(s) Not Found")
- drawStart()
- end
- else
- rednet.send(id,"Data Is Not String")
- end
- end
- function create()
- id, user = rednet.receive()
- id, pass = rednet.receive()
- if type(user) == "string" and type(pass) then
- if fs.exists("user/"..user) then
- rednet.send(id,"User Exists")
- else
- h = fs.open("user/"..user,"w")
- h.write(pass)
- h.close()
- h = fs.open("$/"..user,"w")
- h.write("0")
- h.close()
- rednet.send(id,"Account Created")
- drawStart()
- end
- else
- rednet.send(id,"Data Is Not String")
- end
- drawStart()
- end
- function delete()
- end
- function rename()
- end
- function passcode()
- end
- function add()
- id, user = rednet.receive()
- id, amt = rednet.receive()
- id, auth1 = rednet.receive()
- if type(user) == "string" and type(amt) == "string" and type(auth1) == "string" then
- if tonumber(auth1) == authSet then
- if fs.exists("user/"..user) then
- h = fs.open("$/"..user, "r")
- bal = h.readAll()
- h.close()
- balNew = bal + amt
- h = fs.open("$/"..user, "w")
- h.write(balNew)
- h.close()
- rednet.send(id,"$"..amt.." Added to "..user)
- drawStart()
- else
- rednet.send(id,"No Such User")
- drawStart()
- end
- else
- rednet.send(id,"Authorization Code Not Accepted")
- drawStart()
- end
- else
- rednet.send(id,"Data Is Not String")
- end
- end
- function auth()
- authF()
- rednet.send(id,"New Auth Code Found")
- drawStart()
- end
- function cur(cX,cY)
- term.setCursorPos(cX,cY)
- end
- -- Program
- drawStart()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement