WeaponDamage
Tip
This event is available on server-side only
This event is called when weapon damage occurs
Parameter | Description |
---|---|
player | Player who caused the damage. |
target | Entity who received the damage. |
weapon | The weapon that was used. See: Weapons |
damage | The amount of damage that the target received. |
offset | The offset coordinates caused by the weapon damage the target received. |
bodyPart | Hit body part. |
Normal event handler
Alt.OnWeaponDamage += (player, target, weapon, damage, offset, bodyPart) => {
// ...
return true; // false will cancel the damage sync
}
Attribute event handler
Warning
Attribute event handlers only work in Scripts, or after executing Alt.RegisterEvents on a class instance.
For more info see: Create script
public class MyScript : IScript
{
[ScriptEvent(ScriptEventType.WeaponDamage)]
public void OnWeaponDamage(IPlayer player, IEntity target, uint weapon, ushort damage, Position offset, BodyPart bodyPart)
{
// ...
}
}