OnPlayerClick: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 29: Line 29:
</syntaxhighlight>
</syntaxhighlight>


{{See also/Server event|Player events}}
==See Also==
===Player events===
{{Player_events}}
===Event functions===
{{Event functions}}

Revision as of 02:12, 27 September 2018

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",getRootElement(),outputClick) -- When a player clicks trigger the outputClick function

See Also

Player events


Event functions