It looks like you're new here. If you want to get involved, click one of these buttons!
#include <sourcemod>
#include <clientprefs>
public Plugin:myinfo = {
name = "Damage Indicator",
author = "",
description = "Accurate PVK2 damage and hit indicator via text",
version = "1.0",
url = "http://www.pvkii.com/"
};
bool:block_timer[MAXPLAYERS + 1] = {false,...},
player_damage[MAXPLAYERS + 1],
player_old_health[MAXPLAYERS + 1],
String:DamageEventName[16];
new bool:FrameMod = true;
public OnPluginStart()
{
// Hook all the events and use OnPlayerDamage as callback
HookEvent("player_melee_swing", OnPlayerDamage, EventHookMode_Pre);
HookEvent("player_ranged_impact", OnPlayerDamage, EventHookMode_Pre);
HookEvent("player_bomb_explode", OnPlayerDamage, EventHookMode_Pre);
FrameMod = false;
}
public OnClientConnected(client)
block_timer[client] = false;
public Action:Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
block_timer[client] = false;
return Plugin_Continue;
}
public Action:ShowDamage(Handle:timer, any:client)
{
block_timer[client] = false;
if (player_damage[client] <= 0 || !client || !IsClientInGame(client))
return;
PrintCenterText(client, "%i HP", player_damage[client]);
player_damage[client] = 0;
}
CalcDamage(client, damage)
{
player_damage[client] += damage;
if (block_timer[client])
return;
CreateTimer(0.01, ShowDamage, client);
block_timer[client] = true;
}
public OnGameFrame()
{
if (FrameMod)
{
for (new client = 1; client <= MaxClients; client++)
{
if (IsClientInGame(client))
{
player_old_health[client] = GetClientHealth(client);
}
}
}
}
public Action:OnPlayerDamage(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid")),
damage = GetEventInt(event, "damage");
CalcDamage(client, damage);
return Plugin_Continue;
}
Comments
1. It won't show the exact damage you deal when delivering critical hits (Man-At-Arms' fart).
2. Explosive damage might not be accurate, this is because it may affect friends as well. Also due to it being used to kill multiple targets, not just one, in which case it makes a total damage of all affected targets.
Your soul cannot be saved.