Advertisement
clark

VIPs - Bans

Sep 25th, 2011
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.74 KB | None | 0 0
  1. --[[
  2.     This uses gate keeper. This hook is called as soon as the server receives name, (pass), steamid, ip. Called before PlayerConnect and PlayerAuth. This hook checks for bans and either unbans them or drops them. It also checks to see if the server is full(maxslots - 6) and checks if their vip and allows connection or if not vip denies access and drops them.
  3. --]]
  4. hook.Add("PlayerPasswordAuth" "CheckBans", function( n, p, s, i )
  5.     local ban, vip = tmysql.query("SELECT * `bans`"), tmysql.query("SELECT * `vips`")
  6.     local admin, name, steam, reason, time, vsteam, cid = ban[1][1], ban[1][2], ban[1][3], ban[1][4], ban[1][5], vip[1][1], GetCID( s )
  7.  
  8.     if steam and os.time() >= time then
  9.         tmysql.query("DELETE `bans` WHERE `steamid`='" .. s .. "'")
  10.         Msg(n .. "[" .. s .. "] was unbanned, reason their ban expired.")
  11.     elseif steam then
  12.         if time == 0 then
  13.             return {false, "Your permantly banned from our server(s).\n" .. reason }
  14.         else
  15.             tmysql.query("UPDATE `bans` WHERE `name`='" .. n .. "', `cid`='" .. cid .. "'")
  16.             return {false, "Your banned for " .. time - os.time() .. " minutes.\n" .. reason }
  17.         end
  18.     elseif GetConVar("Maxplayers") - 6 >= gatekeeper.GetNumClients().total then
  19.         if vsteam == s then
  20.             Msg("[VIP][ " .. n .. " | " .. s .. " ] has joined.")
  21.         else
  22.             return {false, "Server is full.\nBuy vip to get reserved slot." }
  23.         end
  24.     end
  25. end)
  26.  
  27. --[[
  28.     http://steamcommunity.com/profiles/7656119xxxxxxxxxx
  29.     steam://friends/add/7656119xxxxxxxxxx
  30. --]]
  31. function GetCID( steamid )
  32.     -- Credit Overv(Evolve Admin Mod)
  33.     local x, y, z = string.match( steamid, "STEAM_(%d+):(%d+):(%d+)" )
  34.     if x and y and z then
  35.         local friendid = string.format( "765%0.f", z * 2 + 61197960265728 + y )
  36.         return friendid
  37.     else
  38.         return steamid
  39.     end
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement