FlacoBey

Untitled

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