Jump to content

Click on Object NEED HELP


CsaliHUN

Recommended Posts

function openthegui
    if getElementType ( targetElem ) == "object" and getElementModel ( targetElem ) == 2778 then
        if showing then
        removeEventHandler("onClientRender", getRootElement(), renderFunc)
        game:destroy()
        window:destroy()
        showCursor(false)
        showing = false
    else
        window = DXWindow(sx/2-(319+10)/2, sy/2-(421+30)/2,319+10, 421+30, "Dream Life - Arcade - 2048", tocolor(255, 136, 0, 150))
        window:setMoveable(true)
        showCursor(true)
        game = Game(window.x + 5,window.y + 25, highscore)
        game:setParent(window)
        addEventHandler("onClientRender", getRootElement(), renderFunc)
        showing = true
    end
addEventHandler ( "onClientClick", getRootElement(), openthegui )

 

Is this good?

Sry for bad english

 

Edited by CsaliHUN
Link to comment

Currently I made this, but it doesn't works

function openthegui
    if getElementType ( clickedElement ) == "object" and getElementModel ( clickedElement ) == 2778 then
        if showing then
        removeEventHandler("onClientRender", getRootElement(), renderFunc)
        game:destroy()
        window:destroy()
        showCursor(false)
        showing = false
    else
        window = DXWindow(sx/2-(319+10)/2, sy/2-(421+30)/2,319+10, 421+30, " ", tocolor(255, 136, 0, 150))
        window:setMoveable(true)
        showCursor(true)
        game = Game(window.x + 5,window.y + 25, highscore)
        game:setParent(window)
        addEventHandler("onClientRender", getRootElement(), renderFunc)
        showing = true
    end
addEventHandler ( "onClientClick", getRootElement(), openthegui )

 

Link to comment

Like this?

function openthegui ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement )
    if getElementType ( clickedElement ) == "object" and getElementModel ( clickedElement ) == 2778 then
        if showing then
        removeEventHandler("onClientRender", getRootElement(), renderFunc)
        game:destroy()
        window:destroy()
        showCursor(false)
        showing = false
    else
        window = DXWindow(sx/2-(319+10)/2, sy/2-(421+30)/2,319+10, 421+30, " ", tocolor(255, 136, 0, 150))
        window:setMoveable(true)
        showCursor(true)
        game = Game(window.x + 5,window.y + 25, highscore)
        game:setParent(window)
        addEventHandler("onClientRender", getRootElement(), renderFunc)
        showing = true
    end
addEventHandler ( "onClientClick", getRootElement(), openthegui )

 

Link to comment

okay, it didn't worked for me, so I started over Like this, but it only opens up when the cursor is on the object.

function openthegui ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement )
    if (guiGetVisible(GUIEditor.window[1])) then -- if the window is visible
		closeWindow() --close
	else
		guiSetVisible(GUIEditor.window[1], true) --else show the window
		setElementData(localPlayer,"2048_active",true,true)
		showCursor(true)
	end
	end
addEventHandler ( "onClientClick", getRootElement(), openthegui )

 

Link to comment
function openthegui(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement)
	if state == "down" then
		if(guiGetVisible(GUIEditor.window[1])) then -- if the window is visible
			closeWindow() --close
		else
			guiSetVisible(GUIEditor.window[1], true) --else show the window
			setElementData(localPlayer,"2048_active",true,true)
			showCursor(true)
		end
	end
end
addEventHandler("onClientClick", getRootElement(), openthegui)

 

Link to comment
8 hours ago, CsaliHUN said:

it only appears when i still holding the cursor on the object

 

Just to make it clear, it only appears while holding or pressing the mouse button because you did not set the state of the button 'up' or 'down'. This way the function will be triggered twice, when you press and when you release the button so it shows up when you press and fades away when hou release because the function was triggered again. < I gave you this advice just in case you did not understand what @NeXuS™ done, and so you dont miss that detail in the future.

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...