Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sdktools>
- #include <sdkhooks>
- #pragma newdecls required
- #pragma semicolon 1
- public void OnPluginStart()
- {
- HookEvent("player_hurt", EventHurt);
- }
- public Action EventHurt(Handle event, const char[] name, bool dontbroadcast)
- {
- int victim = GetClientOfUserId(GetEventInt(event, "userid"));
- int damage = GetEventInt(event, "dmg_health");
- if(bIsSurvivor(victim))
- {
- int HP = GetClientHealth(victim);
- float HealBuf = GetEntPropFloat(victim, Prop_Send, "m_healthBuffer");
- float HealBuff = HP + HealBuf;
- int vForward;
- if(HealBuff - damage < 0)
- {
- vForward = RoundToCeil(HealBuff - damage) * -1;
- DataPack vPack;
- CreateDataTimer(0.1, vApply, vPack, TIMER_DATA_HNDL_CLOSE);
- WritePackCell(vPack, vForward);
- WritePackCell(vPack, victim);
- }
- }
- }
- public Action vApply(Handle timer, DataPack vPack)
- {
- ResetPack(vPack);
- int iAwfull = ReadPackCell(vPack);
- int clinet = ReadPackCell(vPack);
- ForceDamageEntity(clinet, iAwfull, clinet);
- }
- stock bool bIsSurvivor(int client)
- {
- return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
- }
- stock void ForceDamageEntity(int causer, int damage, int victim) // thanks to 达斯*维达
- {
- float victim_origin[3];
- char rupture[32];
- char damage_victim[32];
- IntToString(damage, rupture, sizeof(rupture));
- Format(damage_victim, sizeof(damage_victim), "hurtme%d", victim);
- GetEntPropVector(victim, Prop_Send, "m_vecOrigin", victim_origin);
- int entity = CreateEntityByName("point_hurt");
- DispatchKeyValue(victim, "targetname", damage_victim);
- DispatchKeyValue(entity, "DamageTarget", damage_victim);
- DispatchKeyValue(entity, "Damage", rupture);
- DispatchSpawn(entity);
- TeleportEntity(entity, victim_origin, NULL_VECTOR, NULL_VECTOR);
- AcceptEntityInput(entity, "Hurt", (causer > 0 && causer <= MaxClients) ? causer : -1);
- DispatchKeyValue(entity, "classname", "point_hurt");
- DispatchKeyValue(victim, "targetname", "null");
- AcceptEntityInput(entity, "Kill");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement