You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

53 lines
1.5 KiB

/* Plugin Template generated by Pawn Studio */
#include <sourcemod>
new client_maxhealth[MAXPLAYERS+1];
public Plugin:myinfo =
{
name = "ReflectDmg",
author = "Chefe",
description = "",
version = "1.0",
url = "www.chefgaming.de"
}
public OnPluginStart()
{
//Hooks
HookEvent("player_hurt", Event_PlayerHurt);
HookEvent("player_spawn", Event_PlayerSpawn);
}
public Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
new userid = GetEventInt(event, "userid");
new client = GetClientOfUserId(userid);
if (IsClientInGame(client) && IsPlayerAlive(client))
{
client_maxhealth[client] = GetClientHealth(client);
}
}
public Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
new client_hp = GetEventInt(event, "health");
new client_dmg = GetEventInt(event, "damageamount");
new newhealth;
if (client && attacker && client != attacker)
{
if (client_hp+client_dmg > client_maxhealth[client]) {
newhealth = client_maxhealth[client];
} else {
newhealth = client_hp+client_dmg;
}
//SetEntData(client, FindDataMapOffs(client, "m_iMaxHealth"), client_hp[client], 4, true);
//PrintToChat(client, "[DBG] health-var: %i - dmg-var: %i - attacker: %i - cmb-health: %i", client_hp, client_dmg, attacker, newhealth);
SetEntData(client, FindDataMapOffs(client, "m_iHealth"), newhealth, 4, true);
}
}