Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local playersConnecting = {}
- local playersBanned = {"ip:10.10.10.10", "ip:10.10.10.11"}
- AddEventHandler( "playerConnecting", function( playerName, setCallback )
- table.insert( playersConnecting, bit32.band( source, 0xFFFF ) + 1 )
- end)
- -- GetPlayerEP does not handle NetIDs, only PlayerIDs. Server LUA does not have Citizen.CreateThread nor Wait
- -- so we use this method to periodically check NetIDs converted to PlayerIDs (NetID & 0xFFFF + 1).
- -- Usually triggered when the PlayerID is actually added to the server ~600ms after connecting.
- local function checkPlayersConnecting()
- if #playersConnecting > 0 then
- local EP = GetPlayerEP( playersConnecting[1] )
- if EP ~= nil then
- EP = "ip:" .. EP:Split( ":" )[0]
- for k,v in pairs( playersBanned ) do
- if v == EP then
- DropPlayer( playersConnecting[1], "You are banned." )
- break
- end
- end
- table.remove( playersConnecting, 1 )
- end
- end
- SetTimeout( 175, checkPlayersConnecting )
- end
- SetTimeout( 1, checkPlayersConnecting )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement