Jump to content

On GUI Click Problem


3B00DG4MER

Recommended Posts

Hi Guys i've make 2 buttons as Dx Rectangle but if i add event "onClientGUIClick" but it not working

i tried to add outputchatbox on event but same :/

anyone help

here is Client:

        dxDrawText("Username", 478, 441, 597, 493, tocolor(255, 255, 255, 255), 1.00, bigfont, "center", "center", false, false, true, false, false) 
        dxDrawText("Password", 480, 507, 597, 552, tocolor(255, 255, 255, 255), 1.00, bigfont, "center", "center", false, false, true, false, false) 
    addEventHandler ( "onClientGUIClick", root,  
    function() 
    if source == login or source == register then 
    outputChatBox("Test !!") 
    end 
    end) 

Link to comment

Also 'dxDrawRectangle' returns a boolean only. Almost all DX codes do that.

addEventHandler ( "onClientGUIClick", root, function() 
    local gCursor_pX, gCursor_pY = getCursorPosition() 
480, 590, 122, 52 
    if (gCursor_pX > 480) and (gCursor_pY > 590) and (gCursor_pX < 480+122) and (gCursor_pY < 590+52) then 
        outputChatBox("Test !!") 
    end 
end) 

This would work in your case. (If I didn't do anything wrong) Atleast you can understand what I'm trying to do out of this. I'm checking or the cursor is between the 'dxDrawRectangle' (Login Button) code as soon as you clicked.

If you are going to do it on this way, I prefer a variable for the positions, because if you ever want to change the positions, you don't have to change all positions in the script, only the variable you would have to change by then. ;)

Link to comment

If you type /debugscript 3 you get any errors. Then you would know I forgot to remove "480, 590, 122, 52" out of my code, lol.

addEventHandler ( "onClientGUIClick", root, function() 
    local gCursor_pX, gCursor_pY = getCursorPosition() 
    if (gCursor_pX > 480) and (gCursor_pY > 590) and (gCursor_pX < 480+122) and (gCursor_pY < 590+52) then 
        outputChatBox("Test !!") 
    end 
end) 

Link to comment
If you type /debugscript 3 you get any errors. Then you would know I forgot to remove "480, 590, 122, 52" out of my code, lol.
addEventHandler ( "onClientGUIClick", root, function() 
    local gCursor_pX, gCursor_pY = getCursorPosition() 
    if (gCursor_pX > 480) and (gCursor_pY > 590) and (gCursor_pX < 480+122) and (gCursor_pY < 590+52) then 
        outputChatBox("Test !!") 
    end 
end) 

i removed them

if i tried:

addEventHandler ( "onClientGUIClick", root, function() 
    local gCursor_pX, gCursor_pY = getCursorPosition() 
    outputChatBox(gCursor_pX.." "..gCursor_pY) 
    end 
end) 

it output only on GUI elements only !!

Edited by Guest
Link to comment

By the way, you can also create a GUI button on the same spot as the 'dxDrawRectangle'. Just make it invisible. Also always check with 'isElement' or the button has been created, if not, create it. Then you can just use 'onClientGUIClick'. As soon as you remove the 'dxDrawRectangle' code (When you remove the login screen) then destroy the GUI button with 'destroyElement'.

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