Jump to content

Mouse Click to object


Jumper_Mych

Recommended Posts

huh.. doesn't work type /mouse next nothing

function Mouse ( player ) 
    showCursor ( player, true )  
    else 
    showCursor ( player, false ) 
addCommandHandler ( "mouse", Mouse) 

Doesn't work

local myobject = createObject ( 1300, 2188.064453125, 40.50089263916, 25.705852508545, 0, 0, 0 ) 
  
function addObjectOnClick ( button, state, clickedElement ) 
        if ( clickedElement ) then 
                local elementType = getElementType ( clickedElement ) 
                guiSetText ( myobject, elementType ) 
        guiwin = guiCreateWindow ( 0, 0, 0.5, 0.4, "Information", true ) 
        button = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "Close", true, guiwin ) 
        guiSetVisible ( clickedElement, false ) 
    else 
        guiSetVisible ( clickedElement, true ) 
        end 
end 
addEventHandler ( "onClientClick", getRootElement(), addObjectOnClick ) 

Link to comment

Seriously, you should learn LUA. Not random typing. Where's if-then-else -end?

function Mouse ( player ) 
    if not isCursorShowing ( player ) then 
        showCursor ( player, true )  
    else 
        showCursor ( player, false ) 
    end 
end 
addCommandHandler ( "mouse", Mouse) 

This is wrong, check https://wiki.multitheftauto.com/wiki/OnClientClick

function addObjectOnClick ( button, state, clickedElement ) 
... 
addEventHandler ( "onClientClick", getRootElement(), addObjectOnClick ) 

Wtf is this? You're setting text on an object? guiSetText works ONLY on gui labels (guiCreateLabel)

local myobject = createObject ( 1300, 2188.064453125, 40.50089263916, 25.705852508545, 0, 0, 0 ) 
... 
                guiSetText ( myobject, elementType ) 

How is this supposed to work?

function addObjectOnClick ( button, state, clickedElement ) 
    if ( clickedElement ) then 
        ... 
        guiSetVisible ( clickedElement, false ) 
    else 
        guiSetVisible ( clickedElement, true ) 
    end 
end 

Link to comment

Sorry change to dxDrawText not gui :mrgreen:

And my code doesn't work

local screenWidth, screenHeight = guiGetScreenSize() -- Get the screen resolution 
local myobject = createObject ( 1300, 2188.064453125, 40.50089263916, 25.705852508545, 0, 0, 0 ) 
  
function addObjectOnClick ( player ) 
    if theButton == "left" then 
        dxDrawText( "Object id 1300", 44, screenHeight-41, screenWidth, screenHeight, tocolor(255,200,0,255), 1.02, "clear" ) 
            guiSetVisible ( theButton, false ) 
        else 
            guiSetVisible ( theButton, true ) 
    end 
end 
addEventHandler ( "onClientClick", getRootElement(), addObjectOnClick ) 

Own worth learning LUA. because week for me I was not at my home because forgotten lua

Maybe explained to me how work

because i weak gui therefore teach me maybe understand

Link to comment
Sorry change to dxDrawText not gui :mrgreen:

And my code doesn't work

local screenWidth, screenHeight = guiGetScreenSize() -- Get the screen resolution 
local myobject = createObject ( 1300, 2188.064453125, 40.50089263916, 25.705852508545, 0, 0, 0 ) 
  
function addObjectOnClick ( player ) 
    if theButton == "left" then 
        dxDrawText( "Object id 1300", 44, screenHeight-41, screenWidth, screenHeight, tocolor(255,200,0,255), 1.02, "clear" ) 
            guiSetVisible ( theButton, false ) 
        else 
            guiSetVisible ( theButton, true ) 
    end 
end 
addEventHandler ( "onClientClick", getRootElement(), addObjectOnClick ) 

Own worth learning LUA. because week for me I was not at my home because forgotten lua

Maybe explained to me how work

because i weak gui therefore teach me maybe understand

And where is the button?

Link to comment

1. You can't use dxDrawText and than guiSetVisible because it requires a GUI element.

2. You are missing some paremeters for the function.

3. I don't understand what you want to do but if you want that text stay on the player's screen all the time use onClientRender.If you do not provide it, the text will be rendered for one frame.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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