FlacoBey

Untitled

May 21st, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.96 KB | None | 0 0
  1. #include sdktools
  2.  
  3. #define ZOMBIECLASS_SMOKER  1
  4. #define ZOMBIECLASS_BOOMER  2
  5. #define ZOMBIECLASS_HUNTER  3
  6. #define ZOMBIECLASS_SPITTER 4
  7. #define ZOMBIECLASS_JOCKEY  5
  8. #define ZOMBIECLASS_CHARGER 6
  9. #define ZOMBIECLASS_WITCH   7
  10. #define ZOMBIECLASS_TANK    8
  11.  
  12.  
  13. public OnPluginStart()
  14. {
  15.     HookEvent("tank_spawn", TankSpawned);
  16.     HookEvent("witch_spawn", Witch);
  17. }
  18.  
  19. public OnEntityCreated(entity, const char[] classname)
  20. {
  21.     if(IsCommonInfected(entity))
  22.     {
  23.         CreateTimer(0.1, Timer_CommonSpawn, EntIndexToEntRef(entity), 2);
  24.     }
  25. }
  26.  
  27. public Action Timer_CommonSpawn(Handle timer, any ref)
  28. {
  29.     int entity = -1;
  30.     if(IsValidEntRef(ref))
  31.     {
  32.         entity = EntRefToEntIndex(ref);
  33.     }
  34.     else
  35.     {
  36.         return;
  37.     }
  38.    
  39.     if(entity > 1 && entity < 2049)
  40.     {
  41.         SetEntProp(entity, PropType:1, "m_iHealth", GetRandomInt(1, 500), 4);
  42.     }
  43. }
  44.  
  45. public Action:Witch(Handle:event, const String:ename[], bool:dontBroadcast)
  46. {
  47.     int iWitch = GetEventInt(event, "witchid");
  48.     if(IsWitch(iWitch))
  49.     {
  50.         int iR = GetRandomInt(1, 500)
  51.         SetEntProp(iWitch, PropType:1, "m_iMaxHealth", iR, 4);
  52.         SetEntProp(iWitch, PropType:1, "m_iHealth", iR, 4);
  53.     }
  54. }
  55.  
  56. public Action:TankSpawned(Handle:event, const String:ename[], bool:dontBroadcast)
  57. {
  58.     int iTank = GetClientOfUserId(GetEventInt(event, "userid"));
  59.     if(IsValidInfected(iTank))
  60.     {
  61.         CreateTimer(0.1, timer, iTank, TIMER_FLAG_NO_MAPCHANGE);
  62.     }
  63. }
  64.  
  65. public Action:timer(Handle timer, any client)
  66. {
  67.     if(IsValidInfected(client))
  68.     {
  69.         SetEntityHealth(client, GetRandomInt(29030, 32256));
  70.     }
  71. }
  72.  
  73. public OnClientPutInServer(client)
  74. {
  75.     CreateTimer(0.1, TimerD, client, TIMER_FLAG_NO_MAPCHANGE);
  76. }
  77.  
  78. public Action:TimerD(Handle timer, any client)
  79. {
  80.     if (IsInGame(client))
  81.     {
  82.         if(GetClientTeam(client) == 3)
  83.         {
  84.             new class = GetEntProp(client, Prop_Send, "m_zombieClass");
  85.             if(class == ZOMBIECLASS_SMOKER)
  86.             {
  87.                 SetEntityHealth(client, GetRandomInt(309, 441))
  88.             }
  89.             else if(class == ZOMBIECLASS_BOOMER)
  90.             {
  91.                 SetEntityHealth(client, GetRandomInt(28, 70))
  92.             }
  93.             else if(class == ZOMBIECLASS_HUNTER)
  94.             {
  95.                 SetEntityHealth(client, GetRandomInt(176, 252))
  96.             }
  97.             else if(class == ZOMBIECLASS_SPITTER)
  98.             {
  99.                 SetEntityHealth(client, GetRandomInt(220, 315))
  100.             }
  101.             else if(class == ZOMBIECLASS_JOCKEY)
  102.             {
  103.                 SetEntityHealth(client, GetRandomInt(141, 202))
  104.             }
  105.             else if(class == ZOMBIECLASS_CHARGER)
  106.             {
  107.                 SetEntityHealth(client, GetRandomInt(1613, 2016))
  108.             }
  109.         }
  110.     }
  111. }
  112.  
  113. stock bool:IsValidInfected( client )
  114. {
  115.     if ( client < 1 || client > MaxClients ) return false;
  116.     if ( !IsClientConnected( client )) return false;
  117.     if ( !IsClientInGame( client )) return false;
  118.     if ( GetClientTeam( client ) != 3 ) return false;
  119.     return true;
  120. }
  121.  
  122. stock bool IsWitch(int entity)
  123. {
  124.     if (entity > 0 && IsValidEntity(entity) && IsValidEdict(entity))
  125.     {
  126.         char entType[64];
  127.         GetEdictClassname(entity, entType, sizeof(entType));
  128.         return StrEqual(entType, "witch");
  129.     }
  130.     return false;
  131. }
  132.  
  133. stock bool IsCommonInfected(int entity)
  134. {
  135.     if (entity > 0 && IsValidEntity(entity) && IsValidEdict(entity))
  136.     {
  137.         char entType[64];
  138.         GetEdictClassname(entity, entType, sizeof(entType));
  139.         return StrEqual(entType, "infected");
  140.     }
  141.     return false;
  142. }
  143.  
  144. bool IsValidEntRef(int iEnt)
  145. {
  146.     if( iEnt && EntRefToEntIndex(iEnt) != INVALID_ENT_REFERENCE )
  147.         return true;
  148.     return false;
  149. }
  150.  
  151. stock bool:IsInGame( client )
  152. {
  153.     if ( client < 1 || client > MaxClients ) return false;
  154.     if ( !IsClientConnected( client )) return false;
  155.     if ( !IsClientInGame( client )) return false;
  156.     return true;
  157. }
Advertisement
Add Comment
Please, Sign In to add comment