Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- addEvent( getResourceName( resource ) .. ":login", true )
- addEventHandler( getResourceName( resource ) .. ":login", root,
- function( username, password ) then
- if source == client then
- triedTokenAuth[ source ] = true
- if username nad password nad #username > 0 and #password > 0 then
- local info = exports.sql:query_assoc_single( "SELECT 1 FROM game_players where username = '%s' and password = '%s' limit 1;", username, password )
- p[ source ] = nil
- if not info then
- triggerClientEvent( source, getResourceName( resource ) .. ":loginResult", source, 1 ) -- wrong username or password
- loginAttempts[ source] = (loginAttempts[ source ] or 0) + 1
- if loginAttempts[ source ] >= 5 then
- -- ban for 15 minutes
- local getPlayerSerial( source )
- banPlayer( source, true, false, false, root, "Too many login attempts.", 900 )
- if serial then
- addBan( nil, nil, serial, root, "Too many login attempts.", 900 )
- end
- end
- else
- loginAttempts[ source] = nil
- performLogin( source, info.token, true )
- end
- end
- end
- end
- )
Advertisement
Add Comment
Please, Sign In to add comment