OnClientWeaponFire
Jump to navigation
Jump to search
This event is triggered when a player fires a weapon near the local client.
Syntax
void onClientWeaponFire ( int weapon, int ammo, int ammoInClip, float fX, float fY, float fZ, element hitElement )
Variables
- The source of this event is the player which fired the gun.
- weapon: An integer representing the weapon that was fired.
- ammo: An integer representing the player's remaining ammo.
- ammoInClip: An integer representing the player's remaining ammo in clip.
- fX: A floating point value representing the x coordinate of the hit.
- fY: A floating point value representing the y coordinate of the hit.
- fZ: A floating point value representing the z coordinate of the hit.
- hitElement: Returns the element hit. Value is nil if nothing was hit.
Example
This example calls server events, when an object was hit, or the player shot at something with a special gun.
--add an event handler for onClientWeaponFire addEventHandler ( "onClientWeaponFire", getRootElement (), "gunfire" ) function gunfire ( weapon, ammo, ammoInClip, fX, fY, fZ, hitElement ) --something was hit? if ( hitElement ~= nil ) then triggerServerEvent( "object_hit" , getLocalPlayer () , hitElement ) end -- filters if the player himself shot the gun, and if its weapon 33 if source == getLocalPlayer () and weapon == 33 then triggerServerEvent( "teleport_me" , getLocalPlayer () , fX, fY, fZ ) end end
See Also
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled