Akuba

No Freekill

Jun 14th, 2016
240
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.16 KB | None | 0 0
  1. #include <sourcemod>
  2. //#include <akuba>
  3.  
  4. #define PLUGIN_VERSION      "1.3.3.7"
  5.  
  6. public Plugin:myinfo = {
  7.     name = "No Freekilling",
  8.     author = "Akuba",
  9.     description = "A plugin for Bjorn",
  10.     version = PLUGIN_VERSION
  11. };
  12.  
  13. int Kills[34] = 0; // 32 + console + replay
  14. int KillCheck[34] = -1; // -1 means disabled, -2 means deactivated
  15. Handle hTimer = INVALID_HANDLE;
  16.  
  17. public void OnPluginStart()
  18. {
  19.     HookEvent("player_death", OnPlayerDeath);
  20.     RegAdminCmd("sm_freekill", FreeKillCmd, ADMFLAG_ROOT);
  21.     if(hTimer == INVALID_HANDLE)
  22.     {
  23.         hTimer = CreateTimer(1.0, OnKillTimerCheck, _, TIMER_REPEAT  | TIMER_FLAG_NO_MAPCHANGE);
  24.     }
  25. }
  26.  
  27. public void OnMapStart()
  28. {
  29.     if(hTimer == INVALID_HANDLE)
  30.     {
  31.         hTimer = CreateTimer(1.0, OnKillTimerCheck, _, TIMER_REPEAT  | TIMER_FLAG_NO_MAPCHANGE);
  32.     }
  33. }
  34.  
  35. public Action FreeKillCmd(client, args)
  36. {
  37.     char arg1[32], arg2[32];
  38.     int state = 0;
  39.     char target_name[MAX_TARGET_LENGTH];
  40.     int target_list[MAXPLAYERS], target_count;
  41.     bool tn_is_ml;
  42.     if (args < 1)
  43.     {
  44.         ReplyToCommand(client, "[SM] Usage: sm_freekill <target> [on(1)/off(0)*]");
  45.         return Plugin_Handled;
  46.     }
  47.     if (args >= 2 && GetCmdArg(2, arg2, sizeof(arg2)))
  48.     {
  49.         state = StringToInt(arg2);
  50.     }
  51.     /*decl String:s2[12];
  52.     decl String:targetname[32];
  53.  
  54.     GetCmdArg(1, targetname, sizeof(targetname));
  55.     GetCmdArg(2, s2, sizeof(s2));
  56.  
  57.     new target = FindTarget(client, targetname);
  58.  
  59.     if (IsValidClient(target))
  60.     {
  61.         if(KillCheck[target] != -2)
  62.         {
  63.             KillCheck[target] = -2;
  64.             Kills[target] = 0;
  65.             ReplyToCommand(client, "[SM] You disabled Anti-Freekilling for %N.", target);
  66.             PrintToChat(target, "[SM] An Administrator disabled Anti-Freekilling on you.");
  67.         } else {
  68.             KillCheck[target] = -1;
  69.             Kills[target] = 0;
  70.             ReplyToCommand(client, "[SM] You enabled Anti-Freekilling for %N.", target);
  71.             PrintToChat(target, "[SM] An Administrator enabled Anti-Freekilling on you. Better do not kill someone anymore.");
  72.         }
  73.     }
  74.     else
  75.     {
  76.         ReplyToCommand(client, "[SM] Target is not valid.");
  77.     }*/
  78.  
  79.  
  80.  
  81.     if ((target_count = ProcessTargetString(
  82.             arg1,
  83.             client,
  84.             target_list,
  85.             MAXPLAYERS,
  86.             0, /* Allow All Players, set to COMMAND_FILTER_ALIVE to only select alive players */
  87.             target_name,
  88.             sizeof(target_name),
  89.             tn_is_ml)) <= 0)
  90.     {
  91.         ReplyToTargetError(client, target_count);
  92.         return Plugin_Handled;
  93.     }
  94.  
  95.     for (int i = 0; i < target_count; i++)
  96.     {
  97.         if(state == 1)
  98.         {
  99.             KillCheck[target_list[i]] = -1;
  100.             Kills[target_list[i]] = 0;
  101.             LogAction(client, target_list[i], "\"%L\" enabled Anti-Freekilling for \"%L\".", client, target_list[i]);
  102.             PrintToChat(target_list[i], "[SM] An Administrator enabled Anti-Freekilling on you. Better do not kill someone anymore.");
  103.         }
  104.         else
  105.         {
  106.             KillCheck[target_list[i]] = -2;
  107.             Kills[target_list[i]] = 0;
  108.             LogAction(client, target_list[i], "\"%L\" disabled Anti-Freekilling for \"%L\".", client, target_list[i]);
  109.             PrintToChat(target_list[i], "[SM] An Administrator disabled Anti-Freekilling on you.");
  110.         }
  111.     }
  112.  
  113.     if (tn_is_ml) // Translation needed?
  114.     {
  115.         if(state == 1)
  116.         {
  117.             ShowActivity2(client, "[SM] ", "enabled Anti-Freekilling on %t.", target_name);
  118.         } else {
  119.             ShowActivity2(client, "[SM] ", "disabled Anti-Freekilling on %t.", target_name);
  120.         }
  121.     }
  122.     else
  123.     {
  124.         if(state == 1)
  125.         {
  126.             ShowActivity2(client, "[SM] ", "enabled Anti-Freekilling on %s.", target_name);
  127.         } else {
  128.             ShowActivity2(client, "[SM] ", "disabled Anti-Freekilling on %s.", target_name);
  129.         }
  130.     }
  131.  
  132.     return Plugin_Handled;
  133. }
  134.  
  135. public void OnClientPostAdminCheck(int client)
  136. {
  137.     if(!CheckCommandAccess(client, "sm_freekill_flag", ADMFLAG_ROOT, false))
  138.     {
  139.         Kills[client] = 0;
  140.         KillCheck[client] = -1;
  141.     } else {
  142.         Kills[client] = 0;
  143.         KillCheck[client] = -2;
  144.     }
  145. }
  146.  
  147. public Action OnKillTimerCheck(Handle Timer)
  148. {
  149.     for(new client=1; client<=MaxClients; client++)
  150.     {
  151.         if(KillCheck[client] > 0)
  152.         {
  153.             KillCheck[client]--;
  154.         }
  155.         else if (KillCheck[client] == 0)
  156.         {
  157.             KillCheck[client] = -1;
  158.             Kills[client] = 0;
  159.         }
  160.     }
  161. }
  162.  
  163. public Action OnPlayerDeath(Handle event, const String:name[], bool dontBroadcast)
  164. {
  165.     int iClient = GetClientOfUserId(GetEventInt(event, "userid"));
  166.     int iKiller = GetClientOfUserId(GetEventInt(event, "attacker"));
  167.  
  168.     if(KillCheck[iKiller] == -2) return Plugin_Continue;
  169.  
  170.     if((iKiller > 0 && iKiller <= 32) && IsClientInGame(iKiller) && (iKiller != iClient))
  171.     {
  172.         Kills[iKiller]++;
  173.         if(Kills[iKiller] == 3)
  174.         {
  175.             KillCheck[iKiller] = 60;
  176.             PrintToChat(iKiller, "[SM] You killed 3 people so far. Cooldown for some time or you will be kicked.");
  177.         }
  178.         else if(Kills[iKiller] >= 3)
  179.         {
  180.             KickClient(iKiller, "You have been kicked for Freekilling.");
  181.             return Plugin_Handled;
  182.         }
  183.     }
  184.     return Plugin_Continue;
  185. }
  186.  
  187. stock bool:IsValidClient(client, bool:replaycheck=true)
  188. {
  189.     if(client<=0 || client>MaxClients)
  190.     {
  191.         return false;
  192.     }
  193.  
  194.     if(!IsClientInGame(client))
  195.     {
  196.         return false;
  197.     }
  198.  
  199.     if(GetEntProp(client, Prop_Send, "m_bIsCoaching"))
  200.     {
  201.         return false;
  202.     }
  203.  
  204.     if(replaycheck)
  205.     {
  206.         if(IsClientSourceTV(client) || IsClientReplay(client))
  207.         {
  208.             return false;
  209.         }
  210.     }
  211.     return true;
  212. }
Comments
  • User was banned
Add Comment
Please, Sign In to add comment