OnClientPedWeaponFire: Difference between revisions
Jump to navigation
Jump to search
OpenIDUser27 (talk | contribs) |
No edit summary |
||
(6 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
{{Client event}} | {{Client event}} | ||
__NOTOC__ | __NOTOC__ | ||
This event is called when ped shoots a weapon. This does not trigger for projectiles based, or melee weapons. | This event is called when ped shoots a weapon. This does not trigger for projectiles based, or melee weapons. | ||
{{Note|This event is only triggered for peds that are streamed in}} | |||
==Parameters== | ==Parameters== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
int weapon, int ammo, int ammoInClip, float hitX, float hitY, float hitZ, element hitElement | |||
</syntaxhighlight> | </syntaxhighlight> | ||
*'''weapon''': an [[int]] representing [[weapons|weapon]] used for making a shot. | *'''weapon''': an [[int]] representing [[weapons|weapon]] used for making a shot. | ||
Line 16: | Line 16: | ||
The [[event system#Event source|source]] of this event is the [[ped]] who fired the weapon. | The [[event system#Event source|source]] of this event is the [[ped]] who fired the weapon. | ||
==Example== | ==Example== | ||
<syntaxhighlight lang="lua"> | |||
addEventHandler("onClientPedWeaponFire", root, | |||
function(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) | |||
if isElement(hitElement) and getElementType(hitElement) == "player" then | |||
outputChatBox("You hit " .. getPlayerName(hitElement), 0, 255, 0) | |||
end | |||
end | |||
) | |||
</syntaxhighlight> | |||
==See Also== | ==See Also== |
Latest revision as of 03:12, 30 September 2019
This event is called when ped shoots a weapon. This does not trigger for projectiles based, or melee weapons.
Parameters
int weapon, int ammo, int ammoInClip, float hitX, float hitY, float hitZ, element hitElement
- weapon: an int representing weapon used for making a shot.
- ammo: an int ammount of ammo left for this weapon type.
- ammoInClip: an int ammount of ammo left for this weapon type in clip.
- hitX, hitY, hitZ: float world coordinates representing a hit point.
- hitElement: an element which was hit by a shot.
Source
The source of this event is the ped who fired the weapon.
Example
addEventHandler("onClientPedWeaponFire", root, function(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) if isElement(hitElement) and getElementType(hitElement) == "player" then outputChatBox("You hit " .. getPlayerName(hitElement), 0, 255, 0) end end )
See Also
Client ped events
- onClientPedDamage
- onClientPedHeliKilled
- onClientPedHitByWaterCannon
- onClientPedVehicleEnter
- onClientPedVehicleExit
- onClientPedWasted
- onClientPedWeaponFire
- onClientPedStep
Client event functions
- triggerLatentServerEvent
- triggerServerEvent
- Shared
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled