OnPlayerWeaponShot
Description:
Callback OnPlayerWeaponShot 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).
Known Bug(s):
|
Callback OnPlayerWeaponShot was added in 0.3z and will not work in earlier versions! |
|
GetPlayerLastShotVectors can be used in this callback for more detailed bullet vector information. |
Parameters:
(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
int | playerid | The ID of the player that shot a weapon. |
int | weaponid | The ID of the weapon shot by the player. |
int | hittype | The type of thing the shot hit (none, player, vehicle, or (player)object). |
int | hitid | The ID of the player, vehicle or object that was hit. |
float | fX | The X coordinate that the shot hit. |
float | fY | The Y coordinate that the shot hit. |
float | 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.
Examples:
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; }
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 may be useful, as they are related to this function in one way or another.
- GetPlayerLastShotVectors: Retrieves the vector of the last shot a player fired.