OnWeaponFire: Difference between revisions
Jump to navigation
Jump to search
UniOnDennis (talk | contribs) No edit summary |
Fernando187 (talk | contribs) (Remove obsolete Requirements section) |
||
(10 intermediate revisions by 7 users not shown) | |||
Line 2: | Line 2: | ||
{{Server event}} | {{Server event}} | ||
This event is triggered when a weapon gets fired. | {{New items|3.0140|1.4| | ||
This event is triggered when a custom weapon gets fired. | |||
}} | |||
==Parameters== | |||
No parameters. | |||
==Source== | ==Source== | ||
The [[event system#Event source|source]] of this event is the element that fired the weapon. If the server is the creator it returns ' | The [[event system#Event source|source]] of this event is the element that fired the weapon. If the server is the creator it returns ''nil''. | ||
==Cancel effect== | ==Cancel effect== | ||
If this event is [[Event system#Canceling|canceled]], the bullet(s) won't be synced with other players. | If this event is [[Event system#Canceling|canceled]], the bullet(s) won't be synced with other players. | ||
==Example== | ==Example== | ||
Line 17: | Line 19: | ||
addEventHandler( "onWeaponFire", root, | addEventHandler( "onWeaponFire", root, | ||
function () | function () | ||
if ( isElement( source ) ) and ( getElementType( source ) == "player ) then | if ( isElement( source ) ) and ( getElementType( source ) == "player" ) then | ||
outputChatBox( "You fired a weapon!", source, 0, 225 0 ) | outputChatBox( "You fired a weapon!", source, 0, 225, 0 ) | ||
end | end | ||
end | end | ||
) | ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{See also/Server event| | |||
{{See also/Server event|Weapon events}} | |||
[[ru:OnWeaponFire]] |
Latest revision as of 17:08, 7 November 2024
This event is triggered when a custom weapon gets fired.
Parameters
No parameters.
Source
The source of this event is the element that fired the weapon. If the server is the creator it returns nil.
Cancel effect
If this event is canceled, the bullet(s) won't be synced with other players.
Example
addEventHandler( "onWeaponFire", root, function () if ( isElement( source ) ) and ( getElementType( source ) == "player" ) then outputChatBox( "You fired a weapon!", source, 0, 225, 0 ) end end )
See Also
Weapon events