Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --*****************************
- --********BANQUE CLIENT********
- --*****************************
- --Déclaration des variables
- local monX, monY = term.getSize()
- local user = ""
- local pass = ""
- local idserver = 0
- local whilef = false
- local goodPass = false
- local isRunning = false
- --rondane = "/disk/rednet"
- local publickey = ""
- local crypt = "/disk/crypto"
- os.loadAPI(crypt)
- --os.loadAPI(rondane)
- -- Fin des déclaration des variables
- function keyretriver()
- idserver = rednet.lookup("2banque", "server")
- local messagea = "keyretrive"
- if idserver == nil then
- print("La connection n'a pas plus être établie")
- print("Redémarage")
- sleep(2)
- os.reboot()
- else
- rednet.send(idserver, messagea, "superproto")
- end
- local disable = true
- while disable do
- local si, mess, distance = rednet.receive()
- if si == idserver then
- publickey = mess
- disable = false
- return publickey
- end
- end
- end
- function interfac()
- print("Connection au serveur bancaire...")
- rednet.open("back")
- keyretriver()
- print("Banque interface")
- print("Veuillez entrer votre nom d'utilisateur:")
- user = read()
- print("Veuillez entrer votre mot de passe")
- pass = read("*")
- print("Connection en cours...")
- conn()
- end
- function conn()
- local logintable = {action = "login", User = user, Pass = pass, id = os.getComputerID()}
- login = textutils.serialize(logintable)
- idserver = rednet.lookup("2banque", "server")
- logincrypt = crypto.encrypt(login, publickey)
- rednet.send(idserver, logincrypt, "superproto")
- while whilef == false do
- senderid, message, disance = rednet.receive()
- if senderid == idserver then
- mesge = textutils.unserialize(message)
- if mesge.action == "login" and mesge.user == user then
- whilef = True
- if mesge.response == "yes" then
- print("Vous êtes connecté !")
- sleep(2)
- goodPass = true
- break
- else
- print("Mauvais identifiant")
- break
- end
- end
- end
- end
- whilef = false
- end
- function maininterface()
- isRunning = true
- money = 0
- term.clear()
- term.setCursorPos(1,1)
- x,y = term.getSize()
- paintutils.drawFilledBox(1,1,x,y, colors.lightGray)
- paintutils.drawLine(1,1,x,1, colors.gray)
- term.setCursorPos(1,1)
- term.write("Menu de la banque")
- paintutils.drawPixel(x, 1, colors.red)
- term.setCursorPos(x,1)
- term.write("X")
- term.setCursorPos(1,2)
- term.setBackgroundColor(colors.lightGray)
- term.write("Vous avez : "..money)
- --Création des boutton
- paintutils.drawFilledBox(1,3,x/4,y/4, colors.green)
- --Actions menu
- while isRunning do
- sleep(0.1)
- end
- end
- function closeHandler()
- while isRunning do
- local event, p1, p2, p3 = os.pullEvent("mouse_click")
- --print(p2.."/"..p3)
- if p2 == monX and p3 == 1 then
- isRunning = false
- end
- end
- end
- interfac()
- if goodPass then
- parallel.waitForAll(maininterface, closeHandler)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement