sharivan

multiple_tanks.sp

Jul 23rd, 2017 (edited)
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.53 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3.  
  4. new Handle:g_hTankHealth;
  5. new g_iTankCount;
  6.  
  7. #define MAX_TANKS   2
  8.  
  9. public OnPluginStart()
  10. {
  11.     g_iTankCount = 0;
  12.  
  13.     HookEvent("tank_spawn", tank_spawn);
  14.     g_hTankHealth = CreateConVar("tank_health", "7500");
  15.     CreateTimer(60.0, CheckPlayers, _, TIMER_REPEAT);
  16. }
  17.  
  18. public Action:CheckPlayers(Handle:timer)
  19. {
  20.     new GetSurvivors = GetSurvivorCount();
  21.  
  22.     if (GetSurvivors >= 15)
  23.     {
  24.         if (GetConVarInt(g_hTankHealth) != 65000)
  25.         {
  26.             SetConVarInt(g_hTankHealth, 65000);        
  27.         }
  28.     }
  29.     else if (GetSurvivors >= 13 && GetSurvivors < 15)
  30.     {
  31.         if (GetConVarInt(g_hTankHealth) != 60000)
  32.         {
  33.             SetConVarInt(g_hTankHealth, 60000);        
  34.         }
  35.     }
  36.     else if (GetSurvivors >= 11 && GetSurvivors < 13)
  37.     {
  38.         if (GetConVarInt(g_hTankHealth) != 50000)
  39.         {
  40.             SetConVarInt(g_hTankHealth, 50000);        
  41.         }
  42.     }
  43.     else if (GetSurvivors >= 9 && GetSurvivors < 11)
  44.     {
  45.         if (GetConVarInt(g_hTankHealth) != 40000)
  46.         {
  47.             SetConVarInt(g_hTankHealth, 40000);        
  48.         }
  49.     }
  50.     else if (GetSurvivors >= 5 && GetSurvivors < 9)
  51.     {
  52.         if (GetConVarInt(g_hTankHealth) != 20000)
  53.         {
  54.             SetConVarInt(g_hTankHealth, 20000);        
  55.         }
  56.     }
  57.     else
  58.     {
  59.         if (GetConVarInt(g_hTankHealth) != 7500)
  60.         {
  61.             SetConVarInt(g_hTankHealth, 7500);        
  62.         }
  63.     }
  64.  
  65.     return Plugin_Continue;
  66. }
  67.  
  68. stock GetSurvivorCount()
  69. {
  70.     new hsurvivors = 0;
  71.     for (new i = 1; i <= MaxClients; i++)
  72.     {
  73.         if (IsClientInGame(i) && !IsFakeClient(i))
  74.         {
  75.             hsurvivors++;
  76.         }
  77.     }
  78.  
  79.     return hsurvivors;
  80. }
  81.  
  82. stock SpawnTank()
  83. {
  84.     new flags = GetCommandFlags("z_spawn_old");
  85.     SetCommandFlags("z_spawn_old", flags & ~FCVAR_CHEAT);
  86.     ServerCommand("z_spawn_old tank auto")
  87.     SetCommandFlags("z_spawn_old", flags);
  88. }
  89.  
  90. public tank_spawn(Handle:event, const String:name[], bool:dontBroadcast)
  91. {
  92.     g_iTankCount++;
  93.    
  94.     new userid = GetEventInt(event, "userid");
  95.     new TankHP = GetConVarInt(g_hTankHealth);
  96.     CreateTimer(0.1, tmrHealth, userid);
  97.     PrintToChatAll("\x04[TANK] \x01Um Tank Acabou de Nascer (\x03%i HP\x01)", TankHP);
  98.    
  99.     if (g_iTankCount < MAX_TANKS)
  100.         SpawnTank();
  101. }
  102.  
  103. public Action:tmrHealth(Handle:timer, any:userid)
  104. {
  105.     new client = GetClientOfUserId(userid)
  106.     if (client && IsClientInGame(client))
  107.     {
  108.         SetEntityHealth(client, GetConVarInt(g_hTankHealth));
  109.     }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment