FlacoBey

Untitled

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