OnPlayerWeaponFire: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 27: Line 27:
</syntaxhighlight>
</syntaxhighlight>


{{See also/Server event|Player events}}
==See Also==
===Player events===
{{Player_events}}
===Event functions===
{{Event functions}}

Revision as of 02:18, 27 September 2018

This event is called when a player fires a weapon. This does not trigger for projectiles, melee weapons, or camera.

[[{{{image}}}|link=|]] Note: This event works only with weapons which have enabled bullet sync.

Parameters

int weapon, float endX, float endY, float endZ, element hitElement, float startX, float startY, float startZ
  • weapon: an int representing weapon used for making a shot.
  • endX, endY, endZ: float world coordinates representing an end point.
  • hitElement: an element which was hit by a shot. Currently this can be only another player. Note: hitElement could be incorrect and should not be relied upon.
  • startX, startY, startZ: float world coordinates representing the start of the bullet. Note: This is not the gun muzzle.

Source

The source of this event is the player who fired the weapon.

Example

This code creates explosions when the source players shoots.

addEventHandler ("onPlayerWeaponFire", root, 
   function (weapon, endX, endY, endZ, hitElement, startX, startY, startZ)
       createExplosion(endX, endY, endZ, 2, source);
   end
)

See Also

Player events


Event functions