IncomingDamage
Client-Side Event
C# | JavaScript |
---|
[1.1]
Triggered upon damage that is about to be given to the player.
This event is also cancellable.
JavaScript Syntax
Parameters
- sourceEntity: Object
- sourcePlayer: Object
- targetEntity: Object
- weapon: Int
- boneIndex: Int
- damage: Int
Example
mp.events.add('incomingDamage', (sourceEntity, sourcePlayer, targetEntity, weapon, boneIndex, damage) => { // code });
C# Syntax
Parameters
- sourcePlayer: Player - player (if sourceEntity is Player type) who deals the damage.
- sourceEntity: Entity - entity who deals the damage.
- targetEntity: Entity - target getting the damage.
- weapon: UInt64 - weapon Id used.
- boneIndex: UInt64 - bone index (not id!) hit.
- damage: Int - damage getting dealt (if not canceled).
- cancel: CancelEventArgs - used to cancel the event.
Example
public MyClass() { OnIncomingDamage += OnIncomingDamageHandler; } private void OnIncomingDamageMethod(Player sourcePlayer, Entity sourceEntity, Entity targetEntity, ulong weaponHash, ulong boneIdx, int damage, CancelEventArgs cancel) { // Show bloodscreen if hit from a opponent player from another gang. // IsInSameGang in this example is a custom method in the same class. if (sourcePlayer != null && !IsInSameGang(sourcePlayer)) ShowBloodscreen(); // Also a custom method you have to implement yourself. }
See Also
Browser
Checkpoints
Colshapes
Console
Common
- click
- playerChat
- playerCommand
- playerDeath
- playerJoin
- playerQuit
- playerReady
- playerResurrect
- playerRuleTriggered
- playerSpawn
- playerWeaponShot
- addDataHandler
- dummyEntityCreated
- dummyEntityDestroyed
- entityControllerChange
- replayEditorRequest