Advertisement
FlacoBey

Untitled

Jun 14th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.34 KB | None | 0 0
  1. #pragma semicolon 1
  2. #pragma newdecls required
  3.  
  4. #include <sourcemod>
  5. #include <sdktools>
  6.  
  7. public void OnPluginStart()
  8. {
  9.     HookEvent("infected_hurt", Hurt);
  10. }
  11.  
  12. public Action Hurt (Handle event, const char[] name, bool dontBroadcast)
  13. {
  14.     int entity = GetEventInt(event, "entityid");
  15.     int attacker = GetEventInt(event, "attacker");
  16.     int damagetype = GetEventInt(event, "type");
  17.    
  18.     if(damagetype == 128 && IsCommonInfected(entity) && IsSurvivor(attacker))
  19.     {
  20.         float current[3];
  21.         GetEntPropVector(entity, Prop_Send, "m_vecOrigin", current, 0);
  22.         if(GetRandomInt(-4, 4) >= 0)
  23.             current[0] += 4;
  24.         else
  25.             current[0] -= 4;
  26.         TeleportEntity(entity, current, NULL_VECTOR, NULL_VECTOR);
  27.        
  28.         SetEventInt(event, "amount", 0);
  29.         SetEntProp(entity, Prop_Data, "m_iHealth", 50);
  30.     }
  31. }
  32.  
  33. stock bool IsSurvivor(int client)
  34. {
  35.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  36. }
  37.  
  38. stock bool IsCommonInfected(int entity)
  39. {
  40.     if (entity > 0 && IsValidEntity(entity) && IsValidEdict(entity))
  41.     {
  42.         char entType[64];
  43.         GetEdictClassname(entity, entType, sizeof(entType));
  44.         return StrEqual(entType, "infected");
  45.     }
  46.     return false;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement