FlacoBey

Untitled

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