FlacoBey

Untitled

Dec 25th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.54 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. // #include
  4. int gCount[MAXPLAYERS + 1] = 0;
  5. int g_mapFinale;
  6. public OnPluginStart()
  7. {
  8.     HookEvent("player_use", Event_PlayerUse);
  9.     HookEvent("round_start", Event_RoundStart);
  10. }
  11.  
  12. public OnMapStart()
  13. {
  14.     g_mapFinale = FindEntityByClassname(-1, "trigger_finale") != -1;
  15.    
  16.     if (g_mapFinale)
  17.         UnhookEvent("player_use", Event_PlayerUse);
  18.     else
  19.         HookEvent("player_use", Event_PlayerUse);
  20. }
  21.  
  22. public Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
  23. {
  24.     OnMapStart();
  25. }
  26.  
  27. public Event_PlayerUse(Handle:event, const String:name[], bool:dontBroadcast)
  28. {
  29.     int i = GetClientOfUserId(GetEventInt(event, "userid"));
  30.    
  31.     int entity_id = GetEventInt(event, "targetid");
  32.    
  33.     decl String:ent_name[64];
  34.    
  35.     if (IsValidEdict(entity_id))
  36.     {
  37.         GetEdictClassname(entity_id, ent_name, sizeof(ent_name)); //get the entities name
  38.        
  39.         if (StrEqual(ent_name, "weapon_ammo_spawn", false))
  40.         {
  41.             if(gCount[i] <= 2)
  42.             {
  43.                 gCount[i]++;
  44.             }
  45.             else
  46.             {
  47.                 char buffer[512];
  48.                 Format(buffer, sizeof(buffer), "%N", i);
  49.                 PrintHintTextToAll("%N использовал последнии патроны", i)
  50.                 gCount[i] = 0;
  51.                 AcceptEntityInput(entity_id, "kill")
  52.             }
  53.            
  54.         }
  55.     }
  56.     return;
  57. }
  58.  
  59. stock bool:IsClientInGameHuman(client)
  60. {
  61.     if (client > 0) return IsClientInGame(client) && !IsFakeClient(client);
  62.     else return false;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment