OnPlayerClick: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
(8 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server event}} | {{Server event}} | ||
This event is triggered when a player clicks | This event is triggered when a player clicks using the mouse cursor. | ||
==Parameters== | ==Parameters== | ||
Line 8: | Line 8: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
*'''mouseButton''': | *'''mouseButton''': a [[string]] representing the mouse button that was pressed. Value can be ''left'', ''middle'' or ''right''. | ||
*'''buttonState''': | *'''buttonState''': a [[string]] representing the button state. Value can be ''up'' or ''down''. | ||
*'''clickedElement''': | *'''clickedElement''': the [[element]] the [[player]] clicked on. This value is ''nil'' if none. | ||
*'''worldPosX''': | *'''worldPosX''': the X position in the world the [[player]] clicked on. | ||
*''' | *'''worldPosY''': the Y position in the world the [[player]] clicked on. | ||
*''' | *'''worldPosZ''': the Z position in the world the [[player]] clicked on. | ||
*'''screenPosX''': | *'''screenPosX''': the X position on the screen the [[player]] clicked on. | ||
*'''screenPosY''': | *'''screenPosY''': the Y position on the screen the [[player]] clicked on. | ||
==Source== | ==Source== | ||
The [[event system#Event source|source]] of this event is the [[player]] that clicked. | The [[event system#Event source|source]] of this event is the [[player]] that clicked. | ||
==Example== | ==Example== | ||
This example outputs the state of the button they just pressed. | |||
This example | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | function outputClick(mouseButton, buttonState) | ||
outputChatBox("Your "..mouseButton.." mouse button is now "..buttonState,source,255,255,0) -- output the state of the button they just pressed. | |||
-- | end | ||
addEventHandler("onPlayerClick", root, outputClick) -- When a player clicks trigger the outputClick function | |||
</syntaxhighlight> | </syntaxhighlight> | ||
{{See also/Server event|Player events}} | |||
{{ | |||
Latest revision as of 14:58, 31 December 2022
This event is triggered when a player clicks using the mouse cursor.
Parameters
string mouseButton, string buttonState, element clickedElement, float worldPosX, float worldPosY, float worldPosZ, float screenPosX, float screenPosY
- mouseButton: a string representing the mouse button that was pressed. Value can be left, middle or right.
- buttonState: a string representing the button state. Value can be up or down.
- clickedElement: the element the player clicked on. This value is nil if none.
- worldPosX: the X position in the world the player clicked on.
- worldPosY: the Y position in the world the player clicked on.
- worldPosZ: the Z position in the world the player clicked on.
- screenPosX: the X position on the screen the player clicked on.
- screenPosY: the Y position on the screen the player clicked on.
Source
The source of this event is the player that clicked.
Example
This example outputs the state of the button they just pressed.
function outputClick(mouseButton, buttonState) outputChatBox("Your "..mouseButton.." mouse button is now "..buttonState,source,255,255,0) -- output the state of the button they just pressed. end addEventHandler("onPlayerClick", root, outputClick) -- When a player clicks trigger the outputClick function
See Also
Player events
- onPlayerACInfo
- onPlayerBan
- onPlayerChangeNick
- onPlayerChat
- onPlayerClick
- onPlayerCommand
- onPlayerConnect
- onPlayerContact
- onPlayerDamage
- onPlayerJoin
- onPlayerLogin
- onPlayerLogout
- onPlayerMarkerHit
- onPlayerMarkerLeave
- onPlayerModInfo
- onPlayerMute
- onPlayerNetworkStatus
- onPlayerPickupHit
- onPlayerPickupLeave
- onPlayerPickupUse
- onPlayerPrivateMessage
- onPlayerQuit
- onPlayerScreenShot
- onPlayerSpawn
- onPlayerStealthKill
- onPlayerTarget
- onPlayerUnmute
- onPlayerVehicleEnter
- onPlayerVehicleExit
- onPlayerVoiceStart
- onPlayerVoiceStop
- onPlayerWasted
- onPlayerWeaponFire
- onPlayerWeaponSwitch
Event functions
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled