Advertisement
FlacoBey

Untitled

Jun 9th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.00 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.             DataPack vPack;
  24.             CreateDataTimer(1.0, vApply, vPack, TIMER_DATA_HNDL_CLOSE);
  25.             WritePackCell(vPack, vForward);
  26.             WritePackCell(vPack, victim);
  27.         }
  28.     }
  29. }
  30.  
  31. public Action vApply(Handle timer, DataPack vPack)
  32. {
  33.     ResetPack(vPack);
  34.     int iAwfull = ReadPackCell(vPack);
  35.     int clinet = ReadPackCell(vPack);
  36.     ForceDamageEntity(clinet, iAwfull, clinet);
  37. }
  38.  
  39. stock bool bIsSurvivor(int client)
  40. {
  41.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  42. }
  43.  
  44. stock void ForceDamageEntity(int causer, int damage, int victim) // thanks to 达斯*维达
  45. {
  46.     float victim_origin[3];
  47.     char rupture[32];
  48.     char damage_victim[32];
  49.     IntToString(damage, rupture, sizeof(rupture));
  50.     Format(damage_victim, sizeof(damage_victim), "hurtme%d", victim);
  51.     GetEntPropVector(victim, Prop_Send, "m_vecOrigin", victim_origin);
  52.     int entity = CreateEntityByName("point_hurt");
  53.     DispatchKeyValue(victim, "targetname", damage_victim);
  54.     DispatchKeyValue(entity, "DamageTarget", damage_victim);
  55.     DispatchKeyValue(entity, "Damage", rupture);
  56.     DispatchSpawn(entity);
  57.     TeleportEntity(entity, victim_origin, NULL_VECTOR, NULL_VECTOR);
  58.     AcceptEntityInput(entity, "Hurt", (causer > 0 && causer <= MaxClients) ? causer : -1);
  59.     DispatchKeyValue(entity, "classname", "point_hurt");
  60.     DispatchKeyValue(victim, "targetname", "null");
  61.     AcceptEntityInput(entity, "Kill");
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement