Jump to content

Click a un createObject


aka Blue

Recommended Posts

Funciona pero no sé cómo hacer el trigger :c

local mesa1 = createObject(201, -2107.7, -2283.6001, 30.7, 0, 0, 320) 
  
function clickMesa1(mouse, buttonState, element, playerSource) 
        if (element == mesa1) then 
            triggerClientEvent(playerSource, "abrirMesa", playerSource) 
        end 
end 
addEventHandler("onPlayerClick",root,clickMesa1) 
  
--Client-side 
addEvent("abrirMesa", true) 
addEventHandler("abrirMesa", getRootElement(), 
    function ( ) 
        exports.gui:show('mesa') 
    end 
) 
  

Link to comment

Por que no usas onClientClick?

local mesa1 = createObject(201, -2107.7, -2283.6001, 30.7, 0, 0, 320) 
  
function clickMesa1(mouse, buttonState, element) 
        if element and element == mesa1 then 
            triggerClientEvent(source, "abrirMesa", source) 
        end 
end 
addEventHandler("onPlayerClick",root,clickMesa1) 
  
--Client-side 
addEvent("abrirMesa", true) 
addEventHandler("abrirMesa", getRootElement(), 
    function ( ) 
        exports.gui:show('mesa') 
    end 
) 
  

Link to comment

Mmm sigue sin hacer nada

mesa1= createObject(201, -2107.7, -2283.6001, 30.7, 0, 0, 320) 
  
function asda ( button, state, clickedElement ) 
        if clickedElement == mesa1 then 
            exports.gui:show('mesa') 
            outputChatBox("TEST1") 
        end 
end 
addEventHandler ( "onClientClick", getRootElement(), asda ) 

Link to comment
mesa1= createObject(201, -2107.7, -2283.6001, 30.7, 0, 0, 320) 
  
function asda ( button, state, _, _, _, _, _, clickedElement ) 
        if clickedElement == mesa1 then 
            exports.gui:show('mesa') 
            outputChatBox("TEST1") 
        end 
end 
addEventHandler ( "onClientClick", getRootElement(), asda ) 

Igual, ahora que lo pienso, creo que no sirve con elementos creados pero no pierdes nada intentando.

Link to comment
Que pasaría si en vez de esto pones la segunda opcion?, por curiosidad nada mas, nunca probé ni fui bueno en cliente
addEventHandler ( "onClientClick", getRootElement(), asda ) 

addEventHandler ( "onClientClick", localPlayer, asda ) 

Estarías poniendo el evento solo para el jugador local, me parece que no funcionaría así. Sólo funcionaria si clickeas en "localPlayer".

Link to comment

Si el elemento es server side, por qué no usas https://wiki.multitheftauto.com/wiki/OnElementClicked ?

The source of this event is the element that got clicked by the player.

mouseButton: A string representing the mousebutton that was clicked. This might be left, middle or right.

buttonState: A string representing what state the button clicked is in. This might be up or down.

playerWhoClicked: The player that clicked on the element

clickPosX: The X position in the world the player clicked at

clickPosY: The Y position in the world the player clicked at

clickPosZ: The Z position in the world the player clicked at

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...