sharivan

l4d2_multitanks_zmbr

Sep 27th, 2017 (edited)
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.56 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3.  
  4. new g_TankHealth = 65000;
  5.  
  6. public OnPluginStart()
  7. {
  8.     HookEvent("tank_spawn", Event_TankSpawn);
  9. }
  10.  
  11. public OnPluginEnd()
  12. {
  13.     UnhookEvent("tank_spawn", Event_TankSpawn);
  14. }
  15.  
  16. public Event_TankSpawn(Handle:event, const String:name[], bool:dontBroadcast)
  17. {
  18.     CreateTimer(0.5, TankSpawn, GetEventInt(event, "userid"));
  19. }
  20.  
  21. public Action:TankSpawn(Handle:timer, any:userid)
  22. {
  23.     new client =  GetClientOfUserId(userid);
  24.     if (client == 0)
  25.         return;
  26.  
  27.     SetClientHP(client, GetTankHealth());
  28. }
  29.  
  30. public GetTankHealth()
  31. {
  32.     new survivors = GetSurvivorCount();
  33.  
  34.     if (survivors >= 14)
  35.     {
  36.         if (g_TankHealth != 65000)
  37.         {
  38.             g_TankHealth = 65000;
  39.         }
  40.     }          
  41.     else if (survivors >= 11 && survivors < 14)
  42.     {
  43.         if (g_TankHealth != 40000)
  44.         {
  45.             g_TankHealth = 40000;
  46.         }
  47.     }
  48.     else if (survivors >= 8 && survivors < 11)
  49.     {
  50.         if (g_TankHealth != 25000)
  51.         {
  52.             g_TankHealth = 25000;
  53.         }
  54.     }
  55.     else if (survivors >= 5 && survivors < 8)
  56.     {
  57.         if (g_TankHealth != 12000)
  58.         {
  59.             g_TankHealth = 12000;
  60.         }
  61.     }
  62.     else if (survivors >= 1 && survivors < 5)
  63.     {
  64.         if (g_TankHealth != 5000)
  65.         {
  66.             g_TankHealth = 5000;
  67.         }
  68.     }
  69.    
  70.     return g_TankHealth;
  71. }
  72.  
  73. stock SetClientHP(client, hp)
  74. {
  75.     SetEntProp(client, Prop_Send, "m_iHealth", hp);
  76.     SetEntProp(client, Prop_Send, "m_iMaxHealth", hp);
  77. }
  78.  
  79. stock GetSurvivorCount()
  80. {
  81.     new result = 0;
  82.     for (new i = 1; i <= MaxClients; i++)
  83.     {
  84.         if (IsClientInGame(i) && GetClientTeam(i) == 2 && !IsFakeClient(i))
  85.         {
  86.             result++;
  87.         }
  88.     }
  89.  
  90.     return result;
  91. }
Advertisement
Add Comment
Please, Sign In to add comment