OnClientPlayerHitByWaterCannon: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Remove obsolete Requirements section)
 
(6 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Needs_Example}}
__NOTOC__
__NOTOC__
{{Client event}}
{{Client event}}
This event is fired when a player is hit by a water cannon. Also note that this event is only triggered for players nearby the local player's camera. This is due to elements far away being streamed out.
This event is fired when a player is hit by a water cannon.
{{Note|This event is only triggered for players that are streamed in}}
==Parameters==
==Parameters==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Line 18: Line 18:


==Cancel effect==
==Cancel effect==
If this event is [[Event system#Canceling|canceled]], the Player will not be knocked down
If this event is [[Event system#Canceling|canceled]], the [[player]] will not be knocked down.


==Example==
==Example==
Line 28: Line 28:
         local driver = getVehicleOccupant(source)
         local driver = getVehicleOccupant(source)
         if isElement(driver) then
         if isElement(driver) then
             outputChatBox(""..getPlayerName(player).." is hit by the cannon of "..getPlayerName(driver).."'s vehicle")
             outputChatBox(getPlayerName(player).." is hit by the cannon of "..getPlayerName(driver).."'s vehicle.")
         end
         end
     end
     end
Line 34: Line 34:
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>
==Requirements==
{{Requirements|n/a|1.3.0-9.03931|}}


==See Also==
==See Also==

Latest revision as of 17:04, 7 November 2024

This event is fired when a player is hit by a water cannon.

[[{{{image}}}|link=|]] Note: This event is only triggered for players that are streamed in

Parameters

player playerHit
  • playerHit: the player which got shot by the water cannon

Source

The source of this event is the vehicle who shot the water cannon.

Type

This event is a pre reaction event meaning it occurs before any game level reaction to the collision which include:

  • Players flying off
  • Players being knocked down

Cancel effect

If this event is canceled, the player will not be knocked down.

Example

Click to collapse [-]
Client

This example outputs a message when you are hit by a water cannon

addEventHandler("onClientPlayerHitByWaterCannon",getRootElement(),
    function(player)
        local driver = getVehicleOccupant(source)
        if isElement(driver) then
            outputChatBox(getPlayerName(player).." is hit by the cannon of "..getPlayerName(driver).."'s vehicle.")
        end
    end
)

See Also

Client player events


Client event functions