AXV09

Untitled

May 8th, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. addEvent( getResourceName( resource ) .. ":login", true )
  2. addEventHandler( getResourceName( resource ) .. ":login", root,
  3. function( username, password ) then
  4. if source == client then
  5. triedTokenAuth[ source ] = true
  6. if username nad password nad #username > 0 and #password > 0 then
  7. local info = exports.sql:query_assoc_single( "SELECT 1 FROM game_players where username = '%s' and password = '%s' limit 1;", username, password )
  8. p[ source ] = nil
  9. if not info then
  10. triggerClientEvent( source, getResourceName( resource ) .. ":loginResult", source, 1 ) -- wrong username or password
  11. loginAttempts[ source] = (loginAttempts[ source ] or 0) + 1
  12. if loginAttempts[ source ] >= 5 then
  13. -- ban for 15 minutes
  14. local getPlayerSerial( source )
  15.  
  16. banPlayer( source, true, false, false, root, "Too many login attempts.", 900 )
  17. if serial then
  18. addBan( nil, nil, serial, root, "Too many login attempts.", 900 )
  19. end
  20. end
  21. else
  22. loginAttempts[ source] = nil
  23. performLogin( source, info.token, true )
  24. end
  25. end
  26. end
  27. end
  28. )
Advertisement
Add Comment
Please, Sign In to add comment