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 OnClientPutInServer(int client)
- {
- SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
- }
- public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)
- {
- 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;
- ForceDamageEntity(attacker, vForward, victim);
- }
- }
- }
- 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