Advertisement
Guest User

Untitled

a guest
Jun 21st, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.23 KB | None | 0 0
  1. local PLUGIN = {}
  2.  
  3. PLUGIN.Name = "Bans"
  4. PLUGIN.Author = "RedMist"
  5. PLUGIN.Date = ""
  6. PLUGIN.Filename = PLUGIN_FILENAME
  7. PLUGIN.ClientSide = false
  8. PLUGIN.ServerSide = true
  9. PLUGIN.APIVersion = 2
  10. PLUGIN.Gamemodes = {}
  11.  
  12. if (!SERVER) then return end
  13.  
  14. local PLAYER = FindMetaTable("Player")
  15.  
  16. local function FixedTime ( time )
  17. //if !time then return; end
  18. local fixedTime;
  19. local plural
  20. local months = time / 40320;
  21. local weeks = time / 10080;
  22. local days = time / 1440;
  23. local hours = time / 60;
  24. local minutes = time;
  25.  
  26. //1342828951
  27.  
  28. if time <= 0 then
  29. fixedTime = "Permanent";
  30. elseif time > 40320 then
  31. if months >= 2 then
  32. plural = "'s";
  33. else
  34. plural = "";
  35. end
  36.  
  37. fixedTime = "" .. math.Round(months) .. " Month" .. plural .. "";
  38. elseif time > 10080 then
  39. if weeks >= 2 then
  40. plural = "'s";
  41. else
  42. plural = "";
  43. end
  44.  
  45. fixedTime = "" .. math.Round(weeks) .. " Week" .. plural .. "";
  46. elseif time > 1440 then
  47. if days >= 2 then
  48. plural = "'s";
  49. else
  50. plural = "";
  51. end
  52.  
  53. fixedTime = "" .. math.Round(days) .. " Day" .. plural .. "";
  54. elseif time > 60 then
  55. if hours >= 2 then
  56. plural = "'s";
  57. else
  58. plural = "";
  59. end
  60.  
  61. fixedTime = "" .. math.Round(hours) .. " Hour" .. plural .. "";
  62. else
  63. if minutes >= 2 then
  64. plural = "'s";
  65. else
  66. plural = "";
  67. end
  68.  
  69. fixedTime = "" .. math.Round(minutes) .. " Minute" .. plural .. "";
  70. end
  71.  
  72. return fixedTime;
  73. end
  74.  
  75. function UpdateBT ()
  76. tmysql.query("SELECT `unban_time`, `steamid` FROM `bans`", function ( unbantime )
  77. if unbantime[1] and unbantime[1][1] then
  78. for k, v in pairs(unbantime) do
  79. local numUnbanTime = tonumber(v[1])
  80. local newTime = numUnbanTime - os.time()
  81. newTime = newTime / 60;
  82.  
  83. tmysql.query("UPDATE `server_bans` SET `bans`='" .. FixedTime(newTime) .. "' WHERE `steamid`='" .. v[2] .. "'");
  84. end
  85. end
  86. end)
  87.  
  88. end
  89. timer.Create("UpdateBT", 20, 0, UpdateBT)
  90. concommand.Add("thisisgay", UpdateBT)
  91.  
  92. local function ContinueBan (ply, bannerName, banTime, banReason, Res)
  93. local steamID = ply:SteamID()
  94. local unbanTime = os.time() + (banTime * 60)
  95. local banReasonFixed = tmysql.escape(banReason)
  96. local bannerNameFixed = tmysql.escape(bannerName)
  97. local bannedNameFixed = tmysql.escape(ply:Nick())
  98.  
  99. if (banTime == 0) then
  100. unbanTime = 0
  101. game.ConsoleCommand("banid 0"..steamID)
  102. game.ConsoleCommand("writeid")
  103. end
  104.  
  105. tmysql.query("INSERT INTO `server_bans_logs` (`steamid`, `type`, `committed_by`, `reason`) VALUES ('" .. steamID .. "', 'server ban', '" .. bannerNameFixed .. "', '" .. banReasonFixed .. "')");
  106.  
  107. if Res and Res[1] and Res[1][1] and tonumber(Res[1][1]) >= 5 then
  108. tmysql.query("INSERT INTO `bans` (`steamid`, `unban_time`, `unban_time_fixed`, `banner_name`, `reason`, `banned_name`) VALUES ('" .. steamID .. "', '0', 'Permanent', '" .. bannerNameFixed .. "', 'Struck Out ( " .. banReasonFixed .. " )', '" .. bannedNameFixed .. "')");
  109. ply:Kick('Struck Out ( ' .. banReason .. ' )');
  110. else
  111. tmysql.query("INSERT INTO `bans` (`steamid`, `unban_time`, `unban_time_fixed`, `banner_name`, `reason`, `banned_name`) VALUES ('" .. steamID .. "', '" .. unbanTime .. "', '" .. FixedTime(banTime) .. "', '" .. bannerNameFixed .. "', '" .. banReasonFixed .. "', '" .. bannedNameFixed .. "')");
  112.  
  113. ply:Kick(banReason);
  114. end
  115. end
  116.  
  117. function PLAYER:PDBan ( bannerName, banTime, banReason )
  118. local steamID = self:SteamID()
  119. local unbanTime = os.time() + (banTime * 60)
  120. local monthFromNow = os.time() + (1440 * 60 * 31)
  121. local banReasonFixed = tmysql.escape(banReason)
  122. local bannerNameFixed = tmysql.escape(bannerName)
  123. local bannedNameFixed = tmysql.escape(self:Nick())
  124.  
  125. if (banTime == 0) then unbanTime = 0 end
  126.  
  127. if (banTime >= 1440 or banTime == 0) then
  128. local Res = tmysql.query("UPDATE `ip_intel` SET `strikes`=`strikes`+1 WHERE `steamid` = '" .. steamID .. "'");
  129.  
  130. tmysql.query("INSERT INTO `server_bans_points` (`steamid`, `time`) VALUES ('" .. steamID .. "', '" .. monthFromNow .. "')");
  131.  
  132. tmysql.query("SELECT `strikes` FROM `ip_intel` WHERE `steamid`='" .. steamID .. "'",
  133. function ( Res )
  134. ContinueBan(self, bannerName, banTime, banReason, Res);
  135. end
  136. );
  137. else
  138. ContinueBan(self, bannerName, banTime, banReason);
  139. end
  140. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement