Jump to content

Annoying Thing about onClientClick


The Don

Recommended Posts

showCursor(true) 
local screenW, screenH = guiGetScreenSize() 
  
addEventHandler("onClientRender", root, 
function () 
        dxDrawRectangle(screenW * 0.2875, screenH * 0.3783, screenW * 0.4375, screenH * 0.0933, tocolor(0, 0, 0, 200), false) 
        dxDrawText("360 noscope button", screenW * 0.3625, screenH * 0.4050, screenW * 0.6687, screenH * 0.4550, tocolor(255, 255, 255, 255), 2.00, "default-bold", "left", "top", false, false, false, false, false) 
    end 
) 
  
addEventHandler ( "onClientClick", root,  
function ( Button, State, ScreenX, ScreenY ) 
    if ( ScreenX >= screenW * 0.2875 and ScreenX <= screenW * 0.2875 + screenW * 0.4375 and ScreenY >= screenH * 0.3783 and ScreenY <= screenH * 0.3783 + screenH * 0.0933 ) then 
        outputChatBox ( "360MLG Noscope has been clicked",255,0,0 ) 
    end 
end ) 

there is no errors but the problem that if i clicked i see the message in the chat twice

like this

360MLG Noscope has been clicked 
360MLG Noscope has been clicked 

can any one tell me what i should do :/

Link to comment

You need to check the button state.

showCursor(true) 
local screenW, screenH = guiGetScreenSize() 
  
addEventHandler("onClientRender", root, 
function () 
        dxDrawRectangle(screenW * 0.2875, screenH * 0.3783, screenW * 0.4375, screenH * 0.0933, tocolor(0, 0, 0, 200), false) 
        dxDrawText("360 noscope button", screenW * 0.3625, screenH * 0.4050, screenW * 0.6687, screenH * 0.4550, tocolor(255, 255, 255, 255), 2.00, "default-bold", "left", "top", false, false, false, false, false) 
    end 
) 
  
addEventHandler ( "onClientClick", root, 
function ( Button, State, ScreenX, ScreenY ) 
    if ( State == "down" and ScreenX >= screenW * 0.2875 and ScreenX <= screenW * 0.2875 + screenW * 0.4375 and ScreenY >= screenH * 0.3783 and ScreenY <= screenH * 0.3783 + screenH * 0.0933 ) then 
        outputChatBox ( "360MLG Noscope has been clicked",255,0,0 ) 
    end 
end ) 

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