Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function isIdentifierBanned(identifier)
- local result = MySQL.Sync.fetchAll("SELECT reason,expires FROM bans WHERE banned = @identifier", {['@identifier'] = identifier}
- if result[1] ~= nil then
- local expires = tostring(result[1].expires)
- expires = expires:sub(1, -4)
- expires = tonumber(expires)
- if expires > os.time() then
- return result[1].reason
- else
- MySQL.Sync.execute("DELETE FROM bans WHERE banned = @banned",{['@banned'] = id})
- end
- end
- return false
- end
- AddEventHandler('playerConnecting', function(name, setCallback)
- local identifier = GetPlayerIdentifiers(source)[1]
- print('Checking user ban: ' .. identifier .. " (" .. name .. ")")
- local banned = isIdentifierBanned(identifier)
- if banned ~= false then
- print("(" .. identifier .. ") " .. name .. " has been kicked because it is on the banlist")
- setCallback(banned)
- CancelEvent()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement