OnClientWeaponFire: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(→Example: made no sense) |
||
Line 26: | Line 26: | ||
==Example== | ==Example== | ||
This example prevents | This example prevents player damage from custom weapons. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function | function noDamageToPlayersFromCustomWeapons(target) | ||
if target == localPlayer then | |||
cancelEvent() -- If the weapon hit the player, cancel the shot | |||
end | |||
end | end | ||
addEventHandler("onClientWeaponFire", | addEventHandler("onClientWeaponFire", root, noDamageToPlayersFromCustomWeapons)</syntaxhighlight> | ||
</syntaxhighlight> | |||
==See Also== | ==See Also== | ||
===Client event functions=== | ===Client event functions=== | ||
{{Client_event_functions}} | {{Client_event_functions}} |
Revision as of 18:11, 23 December 2014
This event will be triggered once a client fires his weapon.
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
- triggerLatentServerEvent
- triggerServerEvent
- Shared
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled