FlacoBey

Рандомный урон от бомжей

Jun 20th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.20 KB | None | 0 0
  1. #pragma semicolon 1
  2. #pragma newdecls required
  3.  
  4. #include <sdktools>
  5. #include <sdkhooks>
  6.  
  7. public void OnClientPutInServer(int client)
  8. {
  9.     SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
  10. }
  11.  
  12. public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &ammotype, int hitbox, int hitgroup)
  13. {
  14.     if (!(damagetype & DMG_BURN && damagetype & DMG_BLAST))
  15.     {
  16.         if (IsCommonInfected(attacker))
  17.         {
  18.             if(IsValidClient(victim) && GetClientTeam(victim) == 2)
  19.             {
  20.                 int vClass = GetEntProp(victim, Prop_Send, "m_zombieClass");
  21.                 if (vClass == 9) damage = GetRandomFloat(8.0, 16.0);
  22.                 return Plugin_Changed;
  23.             }
  24.         }
  25.     }
  26.     return Plugin_Continue;
  27. }
  28.  
  29.  stock bool IsCommonInfected(int entity)
  30. {
  31.     if (entity > 0 && IsValidEntity(entity) && IsValidEdict(entity))
  32.     {
  33.         char entType[64];
  34.         GetEdictClassname(entity, entType, sizeof(entType));
  35.         return StrEqual(entType, "infected");
  36.     }
  37.     return false;
  38. }
  39.  
  40. public bool IsValidClient(int client)
  41. {
  42.     if (client <= 0)
  43.         return false;
  44.        
  45.     if (client > MaxClients)
  46.         return false;
  47.        
  48.     if (!IsClientInGame(client))
  49.         return false;
  50.        
  51.     if (!IsPlayerAlive(client))
  52.         return false;
  53.  
  54.     return true;
  55. }
Add Comment
Please, Sign In to add comment