HU/onClientWeaponFire: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
 
No edit summary
 
Line 1: Line 1:
*[[HU/onClientChatMessage]]
{{Client event}}
*[[HU/onClientConsole]]
__NOTOC__
*[[HU/onClientDebugMessage]]
This event triggers when a [[Element/Weapon|custom weapon]] fires a shot.
*[[HU/onClientExplosion]]
{{Note|This event is only for custom weapons that were created with [[createWeapon]], for player held weapons use [[onClientPlayerWeaponFire]].}}
*[[HU/onClientFileDownloadComplete]]
{{Note|This event is only triggered for custom weapons that are streamed in}}
*[[HU/onClientHUDRender]]
==Parameters==
*[[HU/onClientMinimize]]
<syntaxhighlight lang="lua">
*[[HU/onClientPlayerNetworkStatus]]
element hitElement, float posX,  float posY, float posZ, float normalX, float normalY, float normalZ, int materialType, int lighting, int pieceHit
*[[HU/onClientPreRender]]
</syntaxhighlight>
*[[HU/onClientRender]]
*'''hitElement:''' the element that was hit
*[[HU/onClientRestore]]
*'''posX:''' the position it will hit
{{New items|3.0157|1.5.7|
*'''posY:''' the position it will hit
*[[HU/onClientWorldSound]]
*'''posZ:''' the position it will hit
|14652}}
*'''normalX:''' the normal it hit ( see processLineOfSight )
<noinclude>[[Category:Events templates]]</noinclude>
*'''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==
The [[event system#Event source|source]] of this event is the weapon that was fired.
 
==Cancel Effect==
If this event was [[Event system#Canceling|canceled]], then the weapon will not fire.
 
==Example==
This example prevents player damage from custom weapons.
<syntaxhighlight lang="lua">
function noDamageToPlayersFromCustomWeapons(target)
    if target == localPlayer then
        cancelEvent() -- If the weapon hit the player, cancel the shot
    end
end
addEventHandler("onClientWeaponFire", root, noDamageToPlayersFromCustomWeapons)</syntaxhighlight>
 
==See Also==
===Client event functions===
{{Client_event_functions}}
 
[[en:onClientWeaponFire]]

Latest revision as of 11:06, 11 October 2018

This event triggers when a custom weapon fires a shot.

[[{{{image}}}|link=|]] Note: This event is only for custom weapons that were created with createWeapon, for player held weapons use onClientPlayerWeaponFire.
[[{{{image}}}|link=|]] Note: 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, int 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

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

Cancel Effect

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

Example

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

Client event functions