OnClientWeaponFire: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (Added outdated template with link to onClientPlayerWeaponFire) |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Outdated|use [[onClientPlayerWeaponFire]]}} | |||
This event is triggered when a player fires a weapon near the local client. | This event is triggered when a player fires a weapon near the local client. | ||
Revision as of 16:13, 11 November 2011
This article is (partially) outdated and the information may no longer apply. | |
Reason: use onClientPlayerWeaponFire |
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