OnPlayerWeaponFire: Difference between revisions
Jump to navigation
Jump to search
Fernando187 (talk | contribs) m (→Parameters) |
No edit summary |
||
Line 4: | Line 4: | ||
This event is called when a player fires a weapon. This does not trigger for projectiles, melee weapons, or camera. | This event is called when a player fires a weapon. This does not trigger for projectiles, melee weapons, or camera. | ||
}} | }} | ||
{{Note|This event works only with weapons which have enabled bullet sync. See [[Weapons]] for more information. }} | {{Note| | ||
*This event works only with weapons which have enabled bullet sync. See [[Weapons]] for more information. | |||
*Start and end coordinates will be near the center of the map if a player fires a single handed weapon while looking behind them (when the gun is pointed at the sky) | |||
}} | |||
==Parameters== | ==Parameters== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> |
Latest revision as of 14:29, 19 August 2025
This event is called when a player fires a weapon. This does not trigger for projectiles, melee weapons, or camera.
Parameters
int weaponID, float endX, float endY, float endZ, element hitElement, float startX, float startY, float startZ
- weaponID: an int representing weapon used for making a shot.
- endX: float world X coordinate representing the end point.
- endY: float world Y coordinate representing the end point.
- endZ: float world Z coordinate representing the 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: float world X coordinate representing the start of the bullet. Note: This is not the gun muzzle.
- startY: float world Y coordinate representing the start of the bullet.
- startZ: float world Z coordinate representing the start of the bullet.
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
- onPlayerACInfo
- onPlayerBan
- onPlayerChangeNick
- onPlayerChat
- onPlayerClick
- onPlayerCommand
- onPlayerConnect
- onPlayerContact
- onPlayerDamage
- onPlayerJoin
- onPlayerLogin
- onPlayerLogout
- onPlayerMarkerHit
- onPlayerMarkerLeave
- onPlayerModInfo
- onPlayerMute
- onPlayerNetworkStatus
- onPlayerPickupHit
- onPlayerPickupLeave
- onPlayerPickupUse
- onPlayerPrivateMessage
- onPlayerQuit
- onPlayerScreenShot
- onPlayerSpawn
- onPlayerStealthKill
- onPlayerTarget
- onPlayerUnmute
- onPlayerVehicleEnter
- onPlayerVehicleExit
- onPlayerVoiceStart
- onPlayerVoiceStop
- onPlayerWasted
- onPlayerWeaponFire
- onPlayerWeaponSwitch
Event functions
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled