OnClientClick: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
m (→See Also: Added GUI events) |
||
Line 40: | Line 40: | ||
==See Also== | ==See Also== | ||
{{ | ===GUI events=== | ||
{{GUI_events}} | |||
===Client event functions=== | |||
{{Client_event_functions}} |
Revision as of 12:21, 12 January 2008
This event triggers whenever the user clicks his mouse. This is linked to the GTA world, as appose to GUI for which onClientGUIClick is to be used. This event allows detection of click positions of the 3D world.
Parameters
string button, string state, int absoluteX, int absoluteY, float worldX, float worldY, float worldZ, element clickedWorld
- button: This refers the button used to click on the mouse, can be left, right, or middle'
- state: This can be used to tell if the user released or pressed the mouse button, where up is passed if the button is released, and down is passed if the button is pushed
- absoluteX: This refers to the 2D x coordinate the user clicked on his screen, and is an absolute position in pixels.
- absoluteY: This refers to the 2D y coordinate the user clicked on his screen, and is an absolute position in pixels.
- worldX: This represents the 3D x coordinate the player clicked on the screen, and is relative to the GTA world.
- worldY: This represents the 3D y coordinate the player clicked on the screen, and is relative to the GTA world.
- worldZ: This represents the 3D z coordinate the player clicked on the screen, and is relative to the GTA world.
- clickedWorld: This represents any physical entity elements that were clicked.
Source
The source of this event is the client's root element.
Example
This example creates a label when an element is clicked, the label displays in the position of the element telling you what kind of element you have clicked. It hides after 5 seconds.
local myLabel = guiCreateLabel ( 0, 0, 1, 1, "", true ) function addLabelOnClick ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) --if an element was clicked on screen if ( clickedElement ) then --retreive the element type local elementType = getElementType ( clickedElement ) --change the label text to that element type guiSetText ( myLabel, elementType ) --and place it in the position of where the element is guiSetPosition ( myLabel, absoluteX, absoluteY, false ) --hide the text by passing an empty string 5 seconds later setTimer ( guiSetText, 5000, 1, myLabel, "" ) end end addEventHandler ( "onClientClick", getRootElement(), addLabelOnClick )
See Also
GUI events
Input
GUI
- onClientGUIAccepted
- onClientGUIBlur
- onClientGUIChanged
- onClientGUIClick
- onClientGUIComboBoxAccepted
- onClientGUIDoubleClick
- onClientGUIFocus
- onClientGUIMouseDown
- onClientGUIMouseUp
- onClientGUIMove
- onClientGUIScroll
- onClientGUISize
- onClientGUITabSwitched
- onClientMouseEnter
- onClientMouseLeave
- onClientMouseMove
- onClientMouseWheel
Client event functions
- triggerLatentServerEvent
- triggerServerEvent
- Shared
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled