OnPlayerGiveDamage
Description:
Callback OnPlayerGiveDamage is called when a player gives damage to another player.
Callback OnPlayerGiveDamage was added in 0.3d and will not work in earlier versions! |
|
Parameters:
(playerid, damagedid, Float:amount, weaponid, bodypart)
int | playerid | The ID of the player that gave damage. |
int | damagedid | The ID of the player that received damage. |
float | amount | The amount of health/armour damagedid has lost (combined). |
int | weaponid | The reasonAll Weapons that caused the damage. |
int | bodypart | The body part that was hit. (NOTE: This parameter was added in 0.3z. Leave it out if using an older version!) |
Return Values:
- 1 - Callback will not be called in other filterscripts.
- 0 - Allows this callback to be called in other filterscripts.
- It is always called first in filterscripts so returning 1 there blocks other filterscripts from seeing it.
Examples:
public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid, bodypart) { new string[128], victim[MAX_PLAYER_NAME], attacker[MAX_PLAYER_NAME]; new weaponname[24]; GetPlayerName(playerid, attacker, sizeof (attacker)); GetPlayerName(damagedid, victim, sizeof (victim)); GetWeaponName(weaponid, weaponname, sizeof (weaponname)); format(string, sizeof(string), "%s has made %.0f damage to %s, weapon: %s, bodypart: %d", attacker, amount, victim, weaponname, bodypart); SendClientMessageToAll(0xFFFFFFFF, string); return 0; }
Related Callbacks
The following callbacks might be useful as well, as they are related to this callback in one way or another.
- OnPlayerTakeDamage: This callback is called when a player takes damage.
- OnPlayerWeaponShot: Called when a player fires a weapon.