onClientWeaponFire | Multi Theft Auto: Wiki Skip to content

onClientWeaponFire

Client-side
Server-side
Shared

This event triggers when a custom weapon fires a shot.

This event is ONLY for custom weapons that were created with createWeapon , for regular weapons use onClientPlayerWeaponFire .

This event is only triggered for custom weapons that are streamed in

Parameters

element hitElement, float posX, float posY, float posZ, float normalX, float normalY, float normalZ, int materialType, float lighting, int pieceHit
  • hitElement: the element that was hit
  • posX: the position it will hit
  • posY: the position it will hit
  • posZ: the position it will hit
  • normalX: the normal it hit ( see processLineOfSight )
  • normalY: the normal it hit ( see processLineOfSight )
  • normalZ: the normal it hit ( see processLineOfSight )
  • materialType: the material type it hit ( see processLineOfSight )
  • lighting: the lighting of the entity it hit ( see processLineOfSight )
  • pieceHit: the piece of the entity it hit ( see processLineOfSight )

Source

element: The source of this event is the weapon that was fired.

Canceling

If this event was canceled, then the weapon will not fire.

Code Examples

client

This example prevents player damage from custom weapons.

function noDamageToPlayersFromCustomWeapons(target)
if target == localPlayer then
cancelEvent() -- If the weapon hit the player, cancel the shot
end
end
addEventHandler("onClientWeaponFire", root, noDamageToPlayersFromCustomWeapons)

See Also