Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 13th, 2013  |  syntax: None  |  size: 4.79 KB  |  views: 32  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. local PLUGIN = {}
  2.  
  3. PLUGIN.Name = "Default Writer"
  4. PLUGIN.Author = "RedMist"
  5. PLUGIN.Date = "15th March 2011"
  6. PLUGIN.Filename = PLUGIN_FILENAME
  7. PLUGIN.ClientSide = false
  8. PLUGIN.ServerSide = true
  9. PLUGIN.APIVersion = 2
  10. PLUGIN.Gamemodes = {}
  11.  
  12. function PLUGIN.AddToLog(PLAYER, ACL, ACTION) end
  13. function PLUGIN.SaveRankings() end
  14.  
  15. local userGroupToAccess = {}
  16.  
  17. userGroupToAccess[6] = ASS_LVL_SERVER_OWNER
  18. userGroupToAccess[10] = ASS_LVL_SERVER_OWNER
  19. userGroupToAccess[13] = ASS_LVL_SUPER_ADMIN
  20. userGroupToAccess[20] = ASS_LVL_ADMIN
  21. userGroupToAccess[14] = ASS_LVL_PREMIUM
  22. userGroupToAccess[15] = ASS_LVL_DIAMOND
  23. userGroupToAccess[18] = ASS_LVL_GOLD
  24. userGroupToAccess[17] = ASS_LVL_SILVER
  25. userGroupToAccess[16] = ASS_LVL_BRONZE
  26.  
  27. BACKUPIDS = {}
  28.  
  29. function ABI(steamy, rank)
  30. if BACKUPIDS[steamy] then return end
  31. if !rank then return end
  32. BACKUPIDS[steamy] = {}
  33. BACKUPIDS[steamy].Rank = rank
  34. end
  35.  
  36. function Whatsthis( user )
  37.         user:Notify(user:GetLevel())
  38. end
  39. concommand.Add("wtfis", Whatsthis)
  40.  
  41. function RefreshLoadout( Level, user )
  42.         if (Level == 4 || Level < 4 || Level > 4) then
  43.         user:StripWeapons();
  44.         user:Give("roleplay_keys");
  45.         user:Give("roleplay_fists");
  46.         user:Give("weapon_physcannon");
  47.         end
  48.        
  49.         if (Level >= 5) then
  50.                 user:Give("weapon_physgun");
  51.         elseif (Level <= 3) then
  52.                 user:Give("weapon_physgun");
  53.                 user:Give("god_stick");
  54.         else
  55.         end
  56. end
  57.  
  58. function PLUGIN.SetRanks( user )
  59.         if (!user || !IsValid(user) || !user:IsPlayer() || !user.SteamID) then return; end
  60.        
  61.         local steamerid = user:SteamID()
  62.         tmysql.query("SELECT `id_group` FROM `smf_members` WHERE `aim`='" .. steamerid .. "'", function ( GetRank )
  63.        
  64.        
  65.         if (!GetRank || !GetRank[1]) then
  66.                 user:SetLevel(ASS_LVL_GUEST)
  67.                 return;
  68.         end
  69.        
  70.         groupid = GetRank[1][1];
  71.         if (groupid == '1' && user:GetLevel() != ASS_LVL_SERVER_OWNER) then
  72.                 user:Notify("Server Owner")
  73.                 user:SetLevel(ASS_LVL_SERVER_OWNER)
  74.                 RefreshLoadout(1, user)
  75.         elseif (groupid == '2' && user:GetLevel() != ASS_LVL_SUPER_ADMIN) then
  76.                 user:Notify("Super Admin")
  77.                 user:SetLevel(ASS_LVL_SUPER_ADMIN)
  78.                 RefreshLoadout(2, user)
  79.         elseif (groupid == '3' && user:GetLevel() != ASS_LVL_ADMIN) then
  80.                 user:Notify("Admin")
  81.                 user:SetLevel(ASS_LVL_ADMIN)
  82.                 RefreshLoadout(3, user)
  83.         elseif (groupid == '4') then
  84.                 user:Notify("Guest User")
  85.                 user:SetLevel(ASS_LVL_GUEST)
  86.                 RefreshLoadout(4, user)
  87.         elseif (groupid == '5' && user:GetLevel() != ASS_LVL_BRONZE) then
  88.                 user:Notify("Bronze VIP")
  89.                 user:SetLevel(ASS_LVL_BRONZE)
  90.                 RefreshLoadout(5, user)
  91.         elseif (groupid == '6' && user:GetLevel() != ASS_LVL_SILVER) then
  92.                 user:Notify("Silver VIP")
  93.                 user:SetLevel(ASS_LVL_SILVER)
  94.                 RefreshLoadout(6, user)
  95.         elseif (groupid == '7' && user:GetLevel() != ASS_LVL_GOLD) then
  96.                 user:Notify("Gold VIP")
  97.                 user:SetLevel(ASS_LVL_GOLD)
  98.                 RefreshLoadout(7, user)
  99.         elseif (groupid == '8' && user:GetLevel() != ASS_LVL_DIAMOND) then
  100.                 user:Notify("Diamond VIP")
  101.                 user:SetLevel(ASS_LVL_DIAMOND)
  102.                 RefreshLoadout(8, user)
  103.         else
  104.                 //user:Notify("Rank did not change")
  105.         end
  106.         end);
  107. end
  108. hook.Add("PlayerInitialSpawn", "RankInitial", PLUGIN.SetRanks)
  109. //concommand.Add("refreshrank", PLUGIN.SetRanks)
  110. /*
  111. local function RankTimer ()
  112.         if (SERVER) then
  113.                 for k, v in pairs(player.GetAll()) do
  114.                         v:ConCommand("refreshrank");
  115.                 end
  116.         end
  117. end
  118. timer.Create("RankTimer", 30, 0, RankTimer);
  119. */
  120.  
  121.  
  122. if (SERVER) then
  123.  
  124.         //timer.Create("LoadWhateverasdf", 60, 0, PLUGIN.SearchForAdmins)
  125.        
  126.         local lastAttackSpike = 0
  127.         local function monitorAttack ( )
  128.                 if (lastAttackSpike && lastAttackSpike > CurTime()) then return end
  129.        
  130.                 local averagePing = 0
  131.                 local numAvgPlayers = 0
  132.                
  133.                 for _, each in pairs(player.GetAll()) do
  134.                         if (each && IsValid(each) && each:IsPlayer()) then
  135.                                 averagePing = averagePing + each:Ping()
  136.                                 numAvgPlayers = numAvgPlayers + 1
  137.                         end
  138.                 end
  139.                
  140.                 if (numAvgPlayers == 0) then return end
  141.                
  142.                 local averagePing = averagePing / numAvgPlayers
  143.                
  144.                 if (averagePing > 200) then
  145.                         lastAttackSpike = CurTime() + 120
  146.                         RunConsoleCommand("sv_max_queries_sec_global", "1")
  147.                         RunConsoleCommand("sv_max_queries_sec", "1")
  148.                         RunConsoleCommand("sv_max_queries_window", "10")
  149.                        
  150.                         for _, each in pairs(player.GetAll()) do
  151.                                 if (each:IsOwner()) then
  152.                                         each:PrintMessage(HUD_PRINTTALK, "Attack Detected - Reducing max queries...")
  153.                                 end
  154.                         end
  155.                 elseif (lastAttackSpike) then
  156.                         lastAttackSpike = nil
  157.                        
  158.                         RunConsoleCommand("sv_max_queries_sec_global", "100")
  159.                         RunConsoleCommand("sv_max_queries_sec", "3")
  160.                         RunConsoleCommand("sv_max_queries_window", "30")
  161.                        
  162.                         for _, each in pairs(player.GetAll()) do
  163.                                 if (each:IsOwner()) then
  164.                                         each:PrintMessage(HUD_PRINTTALK, "Searching For Attack - Increasing max queries...")
  165.                                 end
  166.                         end
  167.                 end
  168.         end
  169.         //timer.Create("monitorAttack", 5, 0, monitorAttack)
  170. end
  171.  
  172. ASS_RegisterPlugin(PLUGIN)