Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function isIdentifierBanned(id)
- local result = MySQL.Sync.fetchAll("SELECT expires,reason,timestamp FROM bans WHERE banned = @name", {['@name'] = id})
- if(result)then
- for k, v in pairs(result) do
- local expire = tostring(v.expires)
- expire = expire:sub(1, -4)
- expire = tonumber(expire)
- if expire > os.time() then
- return true
- else
- MySQL.Sync.execute("DELETE FROM bans WHERE banned = @banned",{['@banned'] = id})
- end
- end
- end
- return false
- end
- function GetBannedReason(id)
- local result = MySQL.Sync.fetchAll("SELECT expires,reason,timestamp FROM bans WHERE banned = @name", {['@name'] = id})
- if(result)then
- for k,v in ipairs(result)do
- return result[1].reason
- end
- end
- return "No reason"
- end
- AddEventHandler('playerConnecting', function(name, setCallback)
- local identifier = GetPlayerIdentifiers(source)[1]
- print('Checking user ban: ' .. identifier .. " (" .. name .. ")")
- local banned = isIdentifierBanned(identifier)
- if(banned)then
- local reason = GetBannedReason(identifier)
- setCallback(reason)
- CancelEvent()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment