OnClientWeaponFire: Difference between revisions
Jump to navigation
Jump to search
PhatLooser (talk | contribs) No edit summary |
PhatLooser (talk | contribs) |
||
Line 32: | Line 32: | ||
end | end | ||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Event_functions}} | {{Event_functions}} |
Revision as of 09:40, 21 March 2007
This event is triggered when a player switches weapons.
Syntax
void onClientWeaponFire ( [[weapon]] weapon, int ammo, int ammoInClip, float fX, float fY, float fZ, [[element]] hitElement )
Variables
- The source of this event is (clientside) the player which fired the gun.
- weapon: An integer representing the weapon that was fired
- ammo: An integer representing the remaining ammo
- ammoInClip: An integer representing the remaining ammo in clip
- fx fy fz: The coordinates where the shot 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