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 = "Damage and hit indicator",
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()
{
HookEvent("player_hurt", Event_PlayerHurt_FrameMod, EventHookMode_Pre);
FrameMod = true;
HookEvent("player_spawn", Event_PlayerSpawn, EventHookMode_Post);
}
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, client_attacker, damage)
{
if (client != 0)
{
if (client == client_attacker)
return;
}
player_damage[client_attacker] += damage;
if (block_timer[client_attacker])
return;
CreateTimer(0.01, ShowDamage, client_attacker);
block_timer[client_attacker] = true;
}
public OnGameFrame()
{
if (FrameMod)
{
for (new client = 1; client <= MaxClients; client++)
{
if (IsClientInGame(client))
{
player_old_health[client] = GetClientHealth(client);
}
}
}
}
public Action:Event_PlayerHurt_FrameMod(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
new client_attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
new damage = player_old_health[client] - GetClientHealth(client);
CalcDamage(client, client_attacker, damage);
return Plugin_Continue;
}
public Action:Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
{
new client_attacker = GetClientOfUserId(GetEventInt(event, "attacker")),
client = GetClientOfUserId(GetEventInt(event, "userid")),
damage = GetEventInt(event, DamageEventName);
CalcDamage(client, client_attacker, damage);
return Plugin_Continue;
}
public Action:Event_InfectedHurt(Handle:event, const String:name[], bool:dontBroadcast)
{
new client_attacker = GetClientOfUserId(GetEventInt(event, "attacker")),
damage = GetEventInt(event, "amount");
CalcDamage(0, client_attacker, damage);
return Plugin_Continue;
}
Comments
Also if you want to release a plugin, upload the compiled .smx too. Most server admins have no idea on how to compile scripts.
What are exactly PVKII's damage events? I'd like to..."Improve" this "Show Damage" script.
Your soul cannot be saved.