Advertisement
FlacoBey

Untitled

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