Advertisement
henoireil

Untitled

Aug 21st, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.98 KB | None | 0 0
  1. function isIdentifierBanned(identifier)
  2.     local result = MySQL.Sync.fetchAll("SELECT reason,expires FROM bans WHERE banned = @identifier", {['@identifier'] = identifier}
  3.     if result[1] ~= nil then
  4.         local expires = tostring(result[1].expires)
  5.         expires = expires:sub(1, -4)
  6.         expires = tonumber(expires)
  7.         if expires > os.time() then
  8.             return result[1].reason
  9.         else
  10.             MySQL.Sync.execute("DELETE FROM bans WHERE banned = @banned",{['@banned'] = id})
  11.         end
  12.     end
  13.  
  14.     return false
  15. end
  16.  
  17. AddEventHandler('playerConnecting', function(name, setCallback)
  18.     local identifier = GetPlayerIdentifiers(source)[1]
  19.     print('Checking user ban: ' .. identifier .. " (" .. name .. ")")
  20.     local banned = isIdentifierBanned(identifier)
  21.     if banned ~= false then
  22.         print("(" .. identifier .. ") " .. name .. " has been kicked because it is on the banlist")
  23.         setCallback(banned)
  24.         CancelEvent()
  25.     end
  26. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement