Advertisement
FlacoBey

Untitled

Feb 9th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.87 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include sdkhooks
  4.  
  5. static killcount[MAXPLAYERS+1], IsAllowToEquip[MAXPLAYERS+1] = false;
  6. static IndexWp[MAXPLAYERS+1][2];
  7.  
  8. static Handle:hCount = INVALID_HANDLE;
  9.  
  10. static bool:NoDoubleEventFire;
  11.  
  12. public OnPluginStart()
  13. {
  14.     HookEvent("infected_death", hGiveAwp);
  15.     HookEvent("round_start", RoundStartEvent);
  16.    
  17.     hCount = CreateConVar("l4d2_specialammo_killcountsetting", "5", "How much Infected a Player has to shoot to win special ammo. (default 120) ", FCVAR_NONE);
  18.    
  19.     AutoExecConfig(true, "l4d2_specialammo"); // an autoexec! ooooh shiny
  20. }
  21.  
  22. public Action:RoundStartEvent(Handle:event, const String:name[], bool:dontBroadcast)
  23. {
  24.     for (new i = 1; i <= MaxClients; i++)
  25.     {
  26.         killcount[i] = 0;
  27.     }
  28. }
  29.  
  30. public OnClientPutInServer(client)
  31. {
  32.     SDKHook(client, SDKHook_WeaponCanUse, WeaponCanUse);
  33. }
  34.  
  35. public Action:WeaponCanUse(client, weapon)
  36. {
  37.     if(bIsSurvivor(client))
  38.     {
  39.         new wepn = GetPlayerWeaponSlot(client, 1)
  40.         if (!IsValidEntity(wepn))
  41.         {
  42.             return Plugin_Continue;
  43.         }
  44.         decl String:sWeaponExM[32];
  45.         GetEntityClassname(wepn, sWeaponExM, sizeof(sWeaponExM));
  46.        
  47.         if(StrEqual(sWeaponExM, "weapon_sniper_awp"))
  48.         {
  49.             IndexWp[client][1] = wepn
  50.         }
  51.        
  52.         new String:sWeaponEx[64];
  53.         GetEntityClassname(weapon, sWeaponEx, sizeof(sWeaponEx));
  54.            
  55.         if(StrEqual(sWeaponEx, "weapon_sniper_awp") && IndexWp[client][1] != weapon)
  56.         {
  57.             if(!IsAllowToEquip[client])
  58.             {
  59.                 return Plugin_Handled;
  60.             }
  61.         }
  62.     }
  63.     return Plugin_Continue;
  64. }
  65.  
  66. public OnClientDisconnect(client)
  67. {
  68.     killcount[client] = 0;
  69. }
  70.  
  71. public OnClientPostAdminCheck(client)
  72. {
  73.     killcount[client] = 0;
  74. }
  75.  
  76. public Action:hGiveAwp(Handle:event, String:ename[], bool:dontBroadcast)
  77. {
  78.     if (NoDoubleEventFire) return Plugin_Continue;
  79.    
  80.     new client = GetClientOfUserId(GetEventInt(event, "attacker"));
  81.     new bool:minigun = GetEventBool(event, "minigun");
  82.     new bool:blast = GetEventBool(event, "blast");
  83.    
  84.     if (client)
  85.     {
  86.         if (!minigun && !blast)
  87.             killcount[client] += 1;
  88.         else
  89.         {
  90.             NoDoubleEventFire = false;
  91.             return Plugin_Continue;
  92.         }
  93.        
  94.         if ((killcount[client] > GetConVarInt(hCount)))
  95.         {
  96.             if(IsClientInGame(client) && GetClientTeam(client) == 2)
  97.             {
  98.                 IsAllowToEquip[client] = true;
  99.                 killcount[client] = 0;
  100.                 GiveFunction(client, "sniper_awp");
  101.                 IsAllowToEquip[client] = false;
  102.             }
  103.         }
  104.     }
  105.    
  106.     NoDoubleEventFire = false;
  107.     return Plugin_Continue;
  108. }
  109.  
  110. stock bool bIsSurvivor(int client)
  111. {
  112.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && !IsFakeClient(client) && IsPlayerAlive(client);
  113. }
  114.  
  115. void GiveFunction(int client, char[] name)
  116. {
  117.     char sBuf[32];
  118.     int flags = GetCommandFlags("give");
  119.     SetCommandFlags("give", flags & ~FCVAR_CHEAT);
  120.     FormatEx(sBuf, sizeof sBuf, "give %s", name);
  121.     FakeClientCommand(client, sBuf);
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement