Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- side = "right" -- Modem Side
- maintenance2 = "0" -- For Enable 1 or Disable 0 the maintenance
- rednet.open(side) -- Don't Change This (End of Setup)
- term.clear()
- function adminbutton()
- term.setBackgroundColor(colors.orange)
- term.setCursorPos(37,1)
- print(" Admin ")
- end
- function drawStart()
- term.clear()
- term.setCursorPos(1,1)
- print "Bank Server 4.0 Status: Online"
- print "------------------------------"
- adminbutton()
- term.setCursorPos(1,3)
- start()
- end
- function start()
- id, message = rednet.receive()
- if message == "Create" then
- create()
- elseif message == "Login" then
- login()
- elseif message == "Suspend" then
- suspend()
- elseif message == "Delete" then
- delete()
- elseif message == "Balance" then
- balance()
- elseif message == "Transfert" then
- transfert()
- elseif message == "Addfunds" then
- addfunds()
- elseif message == "Withdraw" then
- withdraw()
- elseif message == "Parcelles" then
- parcelles()
- elseif message == "Turtlebankadd" then
- turtlebankadd()
- elseif message == "Turtlebankremove" then
- turtlebankremove()
- elseif message == "Maintenance" then
- maintenance()
- end
- end
- function create()
- id, user = rednet.receive()
- id, pass = rednet.receive()
- if fs.exists("user/"..user) then
- rednet.send(id," L'utilisateur existe deja ")
- term.setBackgroundColor(colors.red)
- print("Connexion de "..id.." Error #1")
- start()
- 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," Compte cree avec succes ")
- term.setBackgroundColor(colors.lime)
- print("Connexion de "..id.." Success #1")
- start()
- end
- end
- function login()
- id, user = rednet.receive()
- id, pass = rednet.receive()
- if type(user) == "string" then
- if type(pass) == "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,"Connexion avec succes")
- term.setBackgroundColor(colors.lime)
- print("Connexion de "..id.." Success #2")
- start()
- else
- rednet.send(id," Mot de passe invalide ")
- term.setBackgroundColor(colors.red)
- print("Connexion de "..id.." Error #2")
- start()
- end
- else
- rednet.send(id," Votre compte n'existe pas ")
- term.setBackgroundColor(colors.red)
- print("Connexion de "..id.." Error #3")
- start()
- end
- end
- end
- end
- function balance()
- id, user = rednet.receive()
- if type(user) == "string" then
- h = fs.open("$/"..user, "r")
- bal = tonumber(h.readAll())
- h.close()
- rednet.send(id,bal)
- term.setBackgroundColor(colors.lime)
- print("Connexion de "..id.." balance "..user)
- start()
- end
- end
- function transfert()
- id, user = rednet.receive()
- id, user2 = rednet.receive()
- id, montantdeduit = rednet.receive()
- if type(user) == "string" then
- h = fs.open("$/"..user, "r")
- bal2 = tonumber(h.readAll())
- h.close()
- h = fs.open("$/"..user2, "r")
- bal3 = tonumber(h.readAll())
- h.close()
- if bal2 >= montantdeduit then
- bal2 = bal2 - montantdeduit
- bal3 = bal3 + montantdeduit
- h = fs.open("$/"..user, "w")
- h.write(bal2)
- h.close()
- h = fs.open("$/"..user2, "w")
- h.write(bal3)
- h.close()
- rednet.send(id," Credits transferer avec succes ")
- term.setBackgroundColor(colors.lime)
- print("Connexion de "..id.." Transfert "..user)
- start()
- else
- rednet.send(id," Credits insuffisant ")
- term.setBackgroundColor(colors.red)
- print("Connexion de "..id.." Transfert Failed "..user)
- start()
- end
- end
- end
- function delete()
- id, user = rednet.receive()
- if type(user) == "string" then
- fs.delete("$/"..user)
- fs.delete("user/"..user)
- rednet.send(id," Votre compte a ete supprimer ")
- term.setBackgroundColor(colors.lime)
- print("Connexion de "..id.." Suppression "..user)
- start()
- end
- end
- function parcelles()
- term.setBackgroundColor(colors.black)
- id, user2 = rednet.receive()
- id, pass = rednet.receive()
- id, atm = rednet.receive()
- h = fs.open("$/"..user2, "r")
- bal2 = tonumber(h.readAll())
- h.close()
- if bal2 >= atm then
- rednet.send(id,"balok")
- if fs.exists("user/"..user2) == true then
- h = fs.open("user/"..user2, "r")
- passReal = h.readAll()
- h.close()
- if pass == passReal then
- rednet.send(id,"passok")
- bal2 = bal2 - atm
- h = fs.open("$/"..user2, "w")
- h.write(bal2)
- h.close()
- term.setBackgroundColor(colors.lime)
- print("Connexion de "..id.." Parcelles Success")
- start()
- else
- term.setBackgroundColor(colors.red)
- print("Connexion de "..id.." Parcelles Failed #1")
- start()
- end
- else
- rednet.send(id,"nop")
- term.setBackgroundColor(colors.red)
- print("Connexion de "..id.." Parcelles Failed #2")
- start()
- end
- else
- rednet.send(id,"nop")
- term.setBackgroundColor(colors.red)
- print("Connexion de "..id.." Parcelles Failed #3")
- start()
- end
- end
- function turtlebankadd()
- id, user2 = rednet.receive()
- id, datavalue = rednet.receive()
- h = fs.open("$/"..user2, "r")
- bal2 = tonumber(h.readAll())
- h.close()
- datavalue = datavalue
- bal3 = bal2 + datavalue
- h = fs.open("$/"..user2, "w")
- h.write(bal3)
- h.close()
- term.setBackgroundColor(colors.lime)
- print("Connexion de "..id.." Ajout de "..datavalue.." a "..user2)
- start()
- end
- function turtlebankremove()
- id, user2 = rednet.receive()
- id, pass = rednet.receive()
- id, datavalue = rednet.receive()
- if fs.exists("user/"..user) == true then
- h = fs.open("user/"..user, "r")
- passReal = h.readAll()
- h.close()
- if pass == passReal then
- h = fs.open("$/"..user2, "r")
- bal2 = tonumber(h.readAll())
- h.close()
- datavalue = datavalue
- bal3 = bal2 - datavalue
- h = fs.open("$/"..user2, "w")
- h.write(bal3)
- h.close()
- rednet.send(id,"successremovebank")
- term.setBackgroundColor(colors.lime)
- print("Connexion de "..id.." Compte deduit "..datavalue.." a "..user)
- start()
- else
- rednet.send(id,"fail2")
- start()
- end
- else
- rednet.send(id,"fail3")
- start()
- end
- start()
- end
- drawStart()
Advertisement
Add Comment
Please, Sign In to add comment