Advertisement
FlacoBey

Untitled

Jun 10th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.12 KB | None | 0 0
  1. #include <sdktools>
  2. #include <sdkhooks>
  3.  
  4. #pragma newdecls required
  5. #pragma semicolon 1
  6.  
  7. public void OnPluginStart()
  8. {
  9.     HookEvent("player_hurt", EventHurt);
  10. }
  11.  
  12. public Action EventHurt(Handle event, const char[] name, bool dontbroadcast)
  13. {
  14.     int victim = GetClientOfUserId(GetEventInt(event, "userid"));
  15.     int damage = GetEventInt(event, "dmg_health");
  16.     if(bIsSurvivor(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.             vForward = RoundToCeil(HealBuff - damage) * -1;
  25.             DataPack vPack;
  26.             CreateDataTimer(0.1, vApply, vPack, TIMER_DATA_HNDL_CLOSE);
  27.             WritePackCell(vPack, vForward);
  28.             WritePackCell(vPack, victim);
  29.         }
  30.     }
  31. }
  32.  
  33. public Action vApply(Handle timer, DataPack vPack)
  34. {
  35.     ResetPack(vPack);
  36.     int iAwfull = ReadPackCell(vPack);
  37.     int clinet = ReadPackCell(vPack);
  38.     ForceDamageEntity(clinet, iAwfull, clinet);
  39. }
  40.  
  41. stock bool bIsSurvivor(int client)
  42. {
  43.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  44. }
  45.  
  46. stock void ForceDamageEntity(int causer, int damage, int victim) // thanks to 达斯*维达
  47. {
  48.     float victim_origin[3];
  49.     char rupture[32];
  50.     char damage_victim[32];
  51.     IntToString(damage, rupture, sizeof(rupture));
  52.     Format(damage_victim, sizeof(damage_victim), "hurtme%d", victim);
  53.     GetEntPropVector(victim, Prop_Send, "m_vecOrigin", victim_origin);
  54.     int entity = CreateEntityByName("point_hurt");
  55.     DispatchKeyValue(victim, "targetname", damage_victim);
  56.     DispatchKeyValue(entity, "DamageTarget", damage_victim);
  57.     DispatchKeyValue(entity, "Damage", rupture);
  58.     DispatchSpawn(entity);
  59.     TeleportEntity(entity, victim_origin, NULL_VECTOR, NULL_VECTOR);
  60.     AcceptEntityInput(entity, "Hurt", (causer > 0 && causer <= MaxClients) ? causer : -1);
  61.     DispatchKeyValue(entity, "classname", "point_hurt");
  62.     DispatchKeyValue(victim, "targetname", "null");
  63.     AcceptEntityInput(entity, "Kill");
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement