OnClientPlayerWeaponFire: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
This event is | This event is called when player shoots a weapon. | ||
==Syntax== | ==Syntax== | ||
Line 8: | Line 6: | ||
void onClientPlayerWeaponFire ( int weapon, int ammo, int ammoInClip, float hitX, float hitY, float hitZ, element hitElement ) | void onClientPlayerWeaponFire ( int weapon, int ammo, int ammoInClip, float hitX, float hitY, float hitZ, element hitElement ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==Parameters== | |||
*The '''source''' of this event refers to the player who made a shot. | |||
*'''weapon''': a [[weapons|weapon]] [[integer]] of a weapon used. | |||
*'''ammo''': an [[integer]] ammount of ammo left for this weapon type. | |||
*'''ammoInClip''': an [[integer]] 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. | |||
==Example== | ==Example== | ||
This example | This example shows player a warning if he hits any other player with minigun. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | -- trigger the event every time player shots | ||
function onClientPlayerWeaponFireFunc(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement ) | |||
-- | if weapon == 38 and getElementType(hitElement)=="player" then -- if player shots from minigun and he hits another player... | ||
outputChatBox ( "Don't kill people with minigun, it's lame!", source ) -- then we output him a warning | |||
end | |||
end | |||
-- add the onClientPlayerWeaponFireFunc function as a handler for onClientPlayerWeaponFire | |||
addEventHandler ( "onPlayerSpawn", getRootElement(), onClientPlayerWeaponFireFunc ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See also== | |||
{{Projectiles functions}} |
Revision as of 21:59, 6 July 2007
This event is called when player shoots a weapon.
Syntax
void onClientPlayerWeaponFire ( int weapon, int ammo, int ammoInClip, float hitX, float hitY, float hitZ, element hitElement )
Parameters
- The source of this event refers to the player who made a shot.
- weapon: a weapon integer of a weapon used.
- ammo: an integer ammount of ammo left for this weapon type.
- ammoInClip: an integer 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.
Example
This example shows player a warning if he hits any other player with minigun.
-- trigger the event every time player shots function onClientPlayerWeaponFireFunc(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement ) if weapon == 38 and getElementType(hitElement)=="player" then -- if player shots from minigun and he hits another player... outputChatBox ( "Don't kill people with minigun, it's lame!", source ) -- then we output him a warning end end -- add the onClientPlayerWeaponFireFunc function as a handler for onClientPlayerWeaponFire addEventHandler ( "onPlayerSpawn", getRootElement(), onClientPlayerWeaponFireFunc )