Advertisement
Guest User

Untitled

a guest
Nov 27th, 2015
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.67 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <cstrike>
  3. #include <sdktools>
  4. #include <colors>
  5. #include <smlib>
  6. #define PLUGIN_VERSION "1.1.1"
  7.  
  8. public Plugin:myinfo = {
  9.     name = "Restrict AWP",
  10.     author = "Dertione",
  11.     description = "restrict AWP",
  12.     version = "1.0",
  13.     url = "http://forum.supreme-elite.fr"
  14. };
  15.  
  16. new g_CountAWP[MAXPLAYERS] = 0;
  17. //new Handle:g_numberAwp;
  18. new numberAwpCT = 0;
  19. new numberAwpT = 0;
  20.  
  21. public OnPluginStart()
  22. {
  23.    
  24.     CreateConVar("g_version", PLUGIN_VERSION, "Plugin by Dertione with kriax", FCVAR_PLUGIN | FCVAR_REPLICATED | FCVAR_NOTIFY);
  25.     //g_numberAwp=CreateConVar("g_numberAwp", "3", "Nombre de flash autorisé pour les non-vip", FCVAR_PLUGIN);
  26.     HookEvent("round_start", Event_RoundStart);
  27.     HookEvent("round_end", Event_RoundEnd, EventHookMode_Pre);
  28. }
  29.  
  30.  
  31.  
  32. public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
  33. {
  34.     new i ;
  35.     numberAwpT = 0;
  36.     numberAwpCT = 0;
  37.     for(i=1;i<=(MAXPLAYERS+1);i++)
  38.     {
  39.         if(IsClientInGame(i) && IsPlayerAlive(i))
  40.         {
  41.             if(Client_HasWeapon(i, "weapon_awp"))
  42.             {
  43.                 g_CountAWP[i]++;
  44.                 if(g_CountAWP[i]>=3)
  45.                 {
  46.                     RemovePlayerItem(i, GetPlayerWeaponSlot(i, 0));
  47.                     Client_RemoveWeapon(i, "weapon_awp", false, false);
  48.                 }
  49.                 else
  50.                 {
  51.                     if(GetClientTeam(i) == 2)
  52.                     {
  53.                         numberAwpT++;
  54.                     }
  55.                     else if(GetClientTeam(i) == 3)
  56.                     {
  57.                         numberAwpCT++;
  58.                     }
  59.                 }
  60.             }
  61.             else
  62.             {
  63.                 g_CountAWP[i] = 0;
  64.             }
  65.         }
  66.     }
  67. }
  68.  
  69. public Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
  70. {
  71.     for(new i=1;i<=(MAXPLAYERS+1);i++)
  72.     {
  73.         if(IsClientInGame(i))
  74.         {
  75.             if(g_CountAWP[i]>=1)
  76.             {
  77.                 g_CountAWP[i]--;
  78.             }
  79.         }
  80.     }
  81. }
  82.  
  83. public Action:CS_OnBuyCommand(client, const String:weapon[])
  84. {
  85.     if (StrEqual(weapon, "awp"))
  86.     {
  87.         if(All_GetPlayerAlive() >= 10)
  88.         {  
  89.             if(g_CountAWP[client] < 1)
  90.             {
  91.                 CPrintToChat(client, "{green}[AWP Restrict] {lightgreen}Vous ne pouvez pas acheter/jouer plus de 3 rounds avec l'awp.");
  92.                 return Plugin_Handled ;
  93.             }
  94.             if(GetClientTeam(client) == 2 && numberAwpT == 0)
  95.             {
  96.                 numberAwpT++;
  97.                 g_CountAWP[client]++;
  98.             }
  99.             else if(GetClientTeam(client) == 3 && numberAwpCT == 0)
  100.             {
  101.                 numberAwpCT++;
  102.                 g_CountAWP[client]++;
  103.             }
  104.             else
  105.             {
  106.                 return Plugin_Handled;
  107.             }
  108.         }
  109.         else
  110.         {
  111.             CPrintToChat(client, "{green}[AWP Restrict] {lightgreen}Vous ne pouvez pas acheter d'awp en dessous de 10 joueurs");
  112.             return Plugin_Handled ;
  113.         }
  114.        
  115.     }
  116.     return Plugin_Continue;
  117. }
  118.  
  119.  
  120. stock All_GetPlayerAlive()
  121. {
  122.     new count;
  123.     for(new i=1; i <= GetMaxClients(); i++)
  124.     {
  125.         if (IsClientInGame(i) && GetClientTeam(i) > 1 && IsPlayerAlive(i))
  126.         {
  127.             count++;
  128.         }
  129.     }
  130.     return count;
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement