Advertisement
Vodka51200

porte mdp avec server coté server

Nov 18th, 2014
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.08 KB | None | 0 0
  1. local client = changeme  --mettre votre speudo
  2. local usr = "changeme"
  3. local pass = "changeme"
  4. rednet.open("back")
  5.  
  6. -- Helper function to split strings at the first line-break ("n").
  7. -- Returns: Two strings representing the first and second half of the given string.
  8. local function splitAtLineBreak( toSplit )
  9.   for i = 1, #toSplit do
  10.   local currChar = string.sub( toSplit, i, i )
  11.   if currChar == "n" then
  12.         firstHalf = string.sub( toSplit, 1, i - 1 )
  13.         secondHalf = string.sub( toSplit, i + 1 )
  14.  
  15.         return firstHalf, secondHalf
  16.   end  -- of IF
  17.   end  -- of FOR
  18. end
  19.  
  20. while true do
  21.   local id, loginDetails
  22.   repeat
  23.         id, loginDetails = rednet.receive()
  24.   until id == client  -- mettre id du computer client
  25.  
  26.   local receivedUser, receivedPass = splitAtLineBreak( loginDetails )
  27.   if receivedUser == usr and receivedPass == pass then
  28.         sleep(5)
  29.         rednet.send(client, "granted") -- remplacer client par id computer client
  30.   else
  31.         sleep(5)
  32.         rednet.send(client, "denied") -- remplacer client par id computer client
  33.   end
  34. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement