OnPlayerDamaged

From GT-MP
Jump to: navigation, search
OnPlayerDamaged
Shared Function
Utilities-terminal.png Server-Side System-users.png Client-Side
Csharp.png C# Javascript.png JavaScript

This event is called when someone takes damage.

Dialog-warning.png Note: This feature is currently not in the API, or is currently not accurate on the wiki due to upcoming API changes. New API functions and changes will be released with the next update.

Requirements

First of all, it should be defined in your Main constructor for it to be called, otherwise it wouldn't be initiated at all!

public Main()
{
    API.onPlayerDamaged += OnPlayerDamagedHandler;
}

Damage Causes

Icon-info.png
  • If the victim takes damage from a source that is not another player, enemy will be null and weaponDamageCause will change based on what hurt the victim.
  • Melee hits are also detected and boneHitID will be -1 when the victim takes melee damage. (Will be fixed in the future)

Damage Cause ID
Object 0
Vehicle 1
PedOrWorld 2

Usage example

private void OnPlayerDamagedHandler(Client victim, Client enemy, int weaponDamageCause, int boneHitId)
{
    API.sendChatMessageToPlayer(victim, "You took damage! | Damage Cause: " + weaponDamageCause + " | Bone: " + boneHitId);
}

References