#include <sdktools_functions>
new Handle:cvar_damage;
public Plugin:myinfo =
{
name = "SM Show Health Victim version",
author = "Franc1sco:franug , thx@R1KO",
description = "Show health victim for attacker",
version = "2.2"
}
public OnPluginStart()
{
CreateConVar("sm_showhealthvictim_version", "2.2", "Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
cvar_damage = CreateConVar("sm_showhealthvictim_damage", "1", "Enable/Disable show damage inflicted too");
HookEvent("player_spawn", Event_PlayerSpawn, EventHookMode_Post);
HookEvent("player_hurt", Event_PlayerHurt);
}
public Action:MostrarVida(Handle:timer, any:Id)
{
new i = GetClientOfUserId(Id);
if (i && IsPlayerAlive(i))
{
new aim = GetClientAimTarget(i, true);
if (0 < aim) PrintHintText(i, "Health Remaining: %i", GetClientHealth(aim));
return Plugin_Continue;
}return Plugin_Stop;
}
public Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) CreateTimer(1.0, MostrarVida, GetEventInt(event, "userid"), TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
public Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
{
new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
if (attacker)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if (client)
{
new restante = GetClientHealth(client);
if (0 < restante)
{
if (GetConVarBool(cvar_damage)) PrintCenterText(attacker, "You did %i Damage to %N\nHealth Remaining: %i", GetEventInt(event, "dmg_health"), client, restante);
else PrintCenterText(attacker, "Health Remaining: %i", restante);
}else PrintCenterText(attacker, "You Killed him");
}
}
}