Advertisement
FlacoBey

Untitled

Jun 9th, 2019
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.70 KB | None | 0 0
  1. #include <sdktools>
  2. #include <sdkhooks>
  3.  
  4. #pragma newdecls required
  5. #pragma semicolon 1
  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)  
  13. {
  14.     if(bIsSurvivor(victim))
  15.     {
  16.         int HP = GetClientHealth(victim);
  17.         float HealBuf = GetEntPropFloat(victim, Prop_Send, "m_healthBuffer");
  18.         float HealBuff = HP + HealBuf;
  19.         int vForward;
  20.         if(HealBuff - damage < 0)
  21.         {
  22.             vForward = RoundToCeil(HealBuff - damage) * -1;
  23.             ForceDamageEntity(attacker, vForward, victim);
  24.         }
  25.     }
  26. }
  27.  
  28. stock bool bIsSurvivor(int client)
  29. {
  30.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  31. }
  32.  
  33. stock void ForceDamageEntity(int causer, int damage, int victim) // thanks to 达斯*维达
  34. {
  35.     float victim_origin[3];
  36.     char rupture[32];
  37.     char damage_victim[32];
  38.     IntToString(damage, rupture, sizeof(rupture));
  39.     Format(damage_victim, sizeof(damage_victim), "hurtme%d", victim);
  40.     GetEntPropVector(victim, Prop_Send, "m_vecOrigin", victim_origin);
  41.     int entity = CreateEntityByName("point_hurt");
  42.     DispatchKeyValue(victim, "targetname", damage_victim);
  43.     DispatchKeyValue(entity, "DamageTarget", damage_victim);
  44.     DispatchKeyValue(entity, "Damage", rupture);
  45.     DispatchSpawn(entity);
  46.     TeleportEntity(entity, victim_origin, NULL_VECTOR, NULL_VECTOR);
  47.     AcceptEntityInput(entity, "Hurt", (causer > 0 && causer <= MaxClients) ? causer : -1);
  48.     DispatchKeyValue(entity, "classname", "point_hurt");
  49.     DispatchKeyValue(victim, "targetname", "null");
  50.     AcceptEntityInput(entity, "Kill");
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement