Przejdź do głównej zawartości

OnNPCGiveDamage

warning

This function was added in omp v1.5.8.3079 and will not work in earlier versions!

Description

This callback is called when an NPC gives damage to a player.

NameDescription
npcidThe ID of the NPC that gave the damage
damagedidThe ID of the player that received the damage
damageThe amount of damage that was given
weaponidThe weapon ID used to give the damage
bodypartThe body part that was hit

Returns

Return false to prevent the damage from being applied, or true to allow it.

Examples

public OnNPCGiveDamage(npcid, damagedid, Float:damage, WEAPON:weaponid, bodypart)
{
// Only notify players tracking this NPC
for (new playerid = 0; playerid < MAX_PLAYERS; playerid++)
{
if (!IsPlayerConnected(playerid))
continue;

if (PlayerNPC[playerid] == npcid)
{
SendClientMessage(playerid, 0xFF8800FF, "NPC %d dealt %.1f damage to player %d (weapon: %d, bodypart: %d)",
npcid, damage, damagedid, _:weaponid, bodypart);
}
}
return 1;
}

Notes

  • This callback is called before the damage is actually applied to the player
  • Returning false will prevent the damage from being applied
  • The bodypart parameter uses the same values as OnPlayerTakeDamage

The following functions might be useful, as they're related to this callback in one way or another.