Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*-------------------------------------------------------------------------------------------------------------------------
- Define Plugin
- -------------------------------------------------------------------------------------------------------------------------*/
- local Plugin = {}
- function Plugin:Load()
- Msg("Ban System Loaded\n")
- end
- require("gatekeeper")
- require( "mysql" )
- local host = "localhost"
- local username = "skillgam"
- local password = "skillgam1"
- local db = "skillgam_smf1"
- function StripForHTTP ( Name, Stop )
- if !Name then return "NA"; end
- Name = mysql.escape(db, Name);
- return tostring(Name);
- end
- /*-------------------------------------------------------------------------------------------------------------------------
- SERVER
- -------------------------------------------------------------------------------------------------------------------------*/
- function Plugin:Server()
- /*-------------------------------------------------------------------------------------------------------------------------
- BAN SID
- -------------------------------------------------------------------------------------------------------------------------*/
- function self.BanSID(sid,time,reason,steam,banner)
- function ASS_ShortBan (sid,time,reason,steam,banner)
- local db, error = mysql.connect(host, username, password, db)
- if time >= (60 * 24) then
- local Res = mysql.query(db, "UPDATE `smf_members` SET `num_bans`=`num_bans`+1 WHERE `steamid`='" .. sid:SteamID() .. "'");
- local numbans = mysql.query(db, "SELECT `num_bans` FROM `smf_members` WHERE `steamid`='" .. sid:SteamID() .. "'");
- ShortBanContinued(sid,time,reason,steam,banner,numbans);
- end
- ShortBanContinued(sid,time,reason,steam,banner);
- end
- function ShortBanContinued (sid,time,reason,steam,banner,Res )
- local db, error = mysql.connect(host, username, password, db)
- if !IsValid(sid) then return false; end
- local SendTime = 0;
- if time == 0 then
- SendTime = 0;
- else
- SendTime = os.time() + (time * 60)
- end
- if Res and Res[1] and Res[1][1] and tonumber(Res[1][1]) >= 5 then
- SendTime = 0;
- end
- local BannerID = banner:SteamID() or "AUTOBOT";
- mysql.query(db, "INSERT INTO `bans` (`ID`, `NAME`, `UNBAN`, `BANNER`, `REASON`, `BANNER_STEAMID`) VALUES ('" .. StripForHTTP(sid:SteamID()) .. "', '" .. StripForHTTP(sid:Nick()) .. "', '" .. StripForHTTP(SendTime)) .. "', '" .. StripForHTTP(banner) .. "', '" .. StripForHTTP(reason) .. "', '" .. BannerID .. "')");
- sid:Kick(REASON);
- local TimeLeft = (time * 60);
- local Minutes = math.floor(TimeLeft / 60);
- local Minutes2 = math.floor(TimeLeft / 60);
- local Seconds = TimeLeft - (Minutes * 60);
- local Hours = math.floor(Minutes / 60);
- local Minutes = Minutes - (Hours * 60);
- local Days = math.floor(Hours / 24);
- local Hours = Hours - (Days * 24);
- local ToDoTime = 0;
- local ToDoWord = "Error";
- if TimeLeft == 0 then
- ToDoWord = "Perma";
- elseif Minutes == 0 and Seconds != 0 then
- ToDoTime = Seconds;
- ToDoWord = "Seconds";
- elseif Hours == 0 and Minutes != 0 then
- ToDoTime = Minutes;
- ToDoWord = "Minutes";
- elseif Days == 0 and Hours != 0 then
- ToDoTime = Hours;
- ToDoWord = "Hours";
- else
- ToDoTime = Days;
- ToDoWord = "Days";
- end
- //if nomessage then return false; end
- if ToDoWord == "Perma" then
- for k, v in pairs(player.GetAll()) do
- v:PrintMessage(HUD_PRINTTALK, sid:Nick() .. " has been banned permanently.");
- v:PrintMessage(HUD_PRINTTALK, "Reason: " .. reason .. ".");
- end
- else
- for k, v in pairs(player.GetAll()) do
- v:PrintMessage(HUD_PRINTTALK, sid:Nick() .. " has been banned for " .. ToDoTime .. " " .. ToDoWord .. ".");
- v:PrintMessage(HUD_PRINTTALK, "Reason: " .. reason .. ".");
- end
- end
- end
- end
- /*-------------------------------------------------------------------------------------------------------------------------
- BAN PLY
- -------------------------------------------------------------------------------------------------------------------------*/
- function self.BanPly(ply,time,reason,banner)
- self.BanSID(ply:WAMID(),time,reason,banner)
- ply:SetNetworkedBool("Ignore_Disconect",true)
- if ( gatekeeper ) then
- gatekeeper.Drop( ply:UserID(), "Banned (" .. reason .. ")" )
- else
- ply:Kick( "Banned (" .. reason .. ")" )
- end
- end
- /*-------------------------------------------------------------------------------------------------------------------------
- Is ID Banned
- -------------------------------------------------------------------------------------------------------------------------*/
- function self.IsBan(sid,steam)
- if steam then
- sid = string.lower(sid)
- sid = string.Replace(sid,":","__")
- end
- if not sid then return end
- local db, error = mysql.connect(host, username, password, db)
- local CheckBans, Success, Error = mysql.query(db, "SELECT `UNBAN` FROM `bans` WHERE `ID`='" .. sid .. "'", mysql.QUERY_FIELDS);
- if !Success then
- return {false, "MySQL Connection Error - Contact Administration"}
- end
- if #CheckBans != 0 then
- local Time = os.time();
- local UnbanTime = tonumber(CheckBans[1]['UNBAN']);
- if UnbanTime == 0 then
- return {false, "You are permanently banned from all Skill Gaming servers."};
- elseif UnbanTime < Time then
- mysql.query(db, "DELETE FROM `bans` WHERE `ID`='" .. sid .. "'");
- elseif UnbanTime >= Time then
- local TimeLeft = UnbanTime - os.time();
- local FormattedTime = string.FormattedTime(UnbanTime - os.time());
- local Minutes = math.floor(TimeLeft / 60);
- local Minutes2 = math.floor(TimeLeft / 60);
- local Seconds = TimeLeft - (Minutes * 60);
- local Hours = math.floor(Minutes / 60);
- local Minutes = Minutes - (Hours * 60);
- local Days = math.floor(Hours / 24);
- local Hours = Hours - (Days * 24);
- if Minutes == 0 then
- return {false, "Banned. Lifted In: " .. Seconds + 1 .. " Seconds"};
- elseif Hours == 0 then
- return {false, "Banned. Lifted In: " .. Minutes + 1 .. " Minutes"};
- elseif Days == 0 then
- return {false, "Banned. Lifted In: " .. Hours + 1 .. " Hours"};
- else
- return {false, "Banned. Lifted In: " .. Days + 1 .. " Days"};
- end
- end
- end
- end
- /*-------------------------------------------------------------------------------------------------------------------------
- UnBann
- -------------------------------------------------------------------------------------------------------------------------*/
- function self.Unban(sid,steam)
- for k, v in pairs(player.GetAll()) do
- v:PrintMessage(HUD_PRINTTALK, sid:Nick() .. " cannot be unbanned! Please use the website to unban players!");
- end
- end
- /*-------------------------------------------------------------------------------------------------------------------------
- PlayerAuthed
- -------------------------------------------------------------------------------------------------------------------------*/
- function self:PlayerAuthed( ply, sid )
- if self.IsBan(sid,true) == true then
- if ( gatekeeper ) then
- gatekeeper.Drop( ply:UserID(), "Banned" )
- else
- ply:Kick( "Banned" )
- end
- ply:SetNetworkedBool("Ignore_Disconect",true)
- end
- end
- /*-------------------------------------------------------------------------------------------------------------------------
- GateKeep Authed
- -------------------------------------------------------------------------------------------------------------------------*/
- function self:PlayerPasswordAuth(name, pass, steam, ip)
- if self.IsBan(steam,true) == true then
- return "Banned"
- end
- return
- end
- /*-------------------------------------------------------------------------------------------------------------------------
- Chat Command To Ban
- -------------------------------------------------------------------------------------------------------------------------*/
- function self.CmdBan(ply,args)
- if not args[1] then return end
- local targ = WAM.Target(args[1],ply)[1]
- if not targ or targ == ply then return "" end
- if not ply:IsRank( targ:GetRank() + 1 ) == true then return "" end
- local time = tonumber(args[2]) or 320
- local reason = args[3] or "Banned By: " .. ply:Name()
- self.BanPly(targ,time,reason,ply)
- end
- WAM.ChatAdd("!ban",self.CmdBan,4,"ban")
- /*-------------------------------------------------------------------------------------------------------------------------
- Ban Steam
- -------------------------------------------------------------------------------------------------------------------------*/
- function self.CmdBan(ply,args)
- local sid = string.lower(args[1])
- if not sid then return end
- if not ply:IsRank( rank + 1 ) == true then return "" end
- local time = tonumber(args[2]) or 320
- local reason = args[3] or "Banned By: " .. ply:Name()
- self.BanSid(sid,time,reason,ply)
- end
- WAM.ChatAdd(nil,self.CmdBan,4,"ban_sid")
- /*-------------------------------------------------------------------------------------------------------------------------
- Ban Steam
- -------------------------------------------------------------------------------------------------------------------------*/
- function self.CmdUnBan(ply,args)
- ply:AddChat("[SYSTEM] ",sid," cannot be unbanned! Please use the website to unban players!")
- end
- WAM.ChatAdd(nil,self.CmdUnBan,4,"unban_sid")
- /*-------------------------------------------------------------------------------------------------------------------------
- TIME -- Thanks to Divran
- -------------------------------------------------------------------------------------------------------------------------*/
- function WAM.TimeExpired(when)
- return when < os.time()
- end
- function WAM.TimeAdd( mins )
- return os.time() + mins
- end
- end
- function Plugin:Client()
- /*-------------------------------------------------------------------------------------------------------------------------
- Ban time Menu
- -------------------------------------------------------------------------------------------------------------------------*/
- function WAM.Ban_Show(ply,Reason)
- if not ply or not ply:IsValid() or not ply:IsPlayer() then return end
- local width = surface.ScreenWidth()
- local height = surface.ScreenHeight()
- local BP = vgui.Create("WolfFrame")
- BP:SetPos((width / 2) - 100, (height / 2) - 50)
- BP:SetSize(170,100)
- BP:SetTitle("Wolf Ban Time:")
- BP:SetDraggable(true)
- BP:SetSizable(false)
- BP:ShowCloseButton(true)
- BP:SetDeleteOnClose(true)
- BP:SetMouseInputEnabled( true )
- local HourL = vgui.Create( "DLabel", BP )
- HourL:SetPos( 5,30 )
- HourL:SetSize( 50,20 )
- HourL:SetText("Hour:")
- local Hour = vgui.Create( "DNumberWang", BP )
- Hour:SetPos( 5,50 )
- Hour:SetSize( 50,20 )
- local MinL = vgui.Create( "DLabel", BP )
- MinL:SetPos( 60,30 )
- MinL:SetSize( 50,20 )
- MinL:SetText("Min:")
- local Min = vgui.Create( "DNumberWang", BP )
- Min:SetPos( 60,50 )
- Min:SetSize( 50,20 )
- local SecL = vgui.Create( "DLabel", BP )
- SecL:SetPos( 115,30 )
- SecL:SetSize( 50,20 )
- SecL:SetText("Sec:")
- local Sec = vgui.Create( "DNumberWang", BP )
- Sec:SetPos( 115,50 )
- Sec:SetSize( 50,20 )
- local Ban = vgui.Create( "WolfButton", BP )
- Ban:SetPos( 5,75 )
- Ban:SetSize( 160,20 )
- Ban:SetText("BAN")
- function Ban:DoClick()
- local time = ( ( ( ( Hour:GetValue() * 60 ) + Min:GetValue() ) * 60 ) + Sec:GetValue() )
- RunConsoleCommand("wam","ban",ply:WAMID(),time,Reason)
- BP:Close()
- end
- BP:MakePopup()
- end
- end
- WAM.RegisterPlug("Ban Core",Plugin)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement