OnPlayerWeaponShot
From SA-MP Wiki
Description:
This callback is called when a player fires a shot from a weapon. Only bullet weapons are supported. Only passenger drive-by is supported (not driver drive-by, and not sea sparrow / hunter shots).
(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
playerid | The ID of the player that shot a weapon. |
weaponid | The ID of the weapon shot by the player. |
hittype | The type of thing the shot hit (none, player, vehicle, or (player)object). |
hitid | The ID of the player, vehicle or object that was hit. |
fX | The X coordinate that the shot hit. |
fY | The Y coordinate that the shot hit. |
fZ | The Z coordinate that the shot hit. |
Return Values:
- 0 - Prevent the bullet from causing damage.
- 1 - Allow the bullet to cause damage.
- It is always called first in filterscripts so returning 0 there also blocks other scripts from seeing it.
Notes |
- BULLET_HIT_TYPE_NONE: the fX, fY and fZ parameters are normal coordinates, will give 0.0 for coordinates if nothing was hit (e.g. far object that the bullet can't reach); |
Example Usage:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ) { new szString[144]; format(szString, sizeof(szString), "Weapon %i fired. hittype: %i hitid: %i pos: %f, %f, %f", weaponid, hittype, hitid, fX, fY, fZ); SendClientMessage(playerid, -1, szString); return 1; }
Tip | GetPlayerLastShotVectors can be used in this callback for more detailed bullet vector information. |
Related Callbacks
The following callbacks might be useful as well, as they are related to this callback in one way or another.
- OnPlayerGiveDamage: This callback is called when a player gives damage.
Related Functions
The following functions might be useful, as they're related to this callback in one way or another.
- GetPlayerLastShotVectors: Retrieves the vector of the last shot a player fired.