Advertisement
Guest User

Untitled

a guest
Jan 8th, 2017
558
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local playersConnecting = {}
  2. local playersBanned = {"ip:10.10.10.10", "ip:10.10.10.11"}
  3.  
  4. AddEventHandler( "playerConnecting", function( playerName, setCallback )
  5.     table.insert( playersConnecting, bit32.band( source, 0xFFFF ) + 1 )
  6. end)
  7.  
  8. -- GetPlayerEP does not handle NetIDs, only PlayerIDs. Server LUA does not have Citizen.CreateThread nor Wait
  9. -- so we use this method to periodically check NetIDs converted to PlayerIDs (NetID & 0xFFFF + 1).
  10. -- Usually triggered when the PlayerID is actually added to the server ~600ms after connecting.
  11. local function checkPlayersConnecting()
  12.     if #playersConnecting > 0 then
  13.         local EP = GetPlayerEP( playersConnecting[1] )
  14.        
  15.         if EP ~= nil then
  16.             EP = "ip:" .. EP:Split( ":" )[0]
  17.            
  18.             for k,v in pairs( playersBanned ) do
  19.                 if v == EP then
  20.                     DropPlayer( playersConnecting[1], "You are banned." )
  21.                     break
  22.                 end
  23.             end
  24.            
  25.             table.remove( playersConnecting, 1 )
  26.         end
  27.     end
  28.    
  29.     SetTimeout( 175, checkPlayersConnecting )
  30. end
  31.  
  32. SetTimeout( 1, checkPlayersConnecting )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement