Jump to content

DX Buttons help


Anubhav

Recommended Posts

Ok I was researching for clicks on buttons. I got it but, I'm expierencing a issue

I'm having multiple buttons so I'm using up a loop now the problem is

Button 1

Button 2

Button 3

Button 4

Button 5

If I click button 1 no problem

If I click button 2:it outputs button 1 then button 2

If I click button 3:it outputs button 3 then button 1 then button 2

If I click button 4:it outputs button 4 then button 3 then button 1 then button 2

If I click button 5:it outputs button 4 then button 3 then button 1 then button 5 then button 2

What could be the problem?

  
addEventHandler( "onClientClick", root, 
    function( button, state, x, y ) 
        if (button == "left") and (state == "up") and (showing) then 
            local index = 0 
            for i, v in pairs( rules ) do 
                index = index + 1 
                if ( x >= rules[ i ].acceptX and x <= rules[ i ].acceptX + rules[ i ].acceptW and y >= rules[ i ].acceptY and y <= rules[ i ].acceptY + rules[ i ].acceptH ) then 
                    currentText = rulesInfo[ index ] 
                    if colorSet then 
                        rules[ colorSet ].color = tocolor( 255, 255, 255, 255 ) 
                    end 
                    colorSet = false  
                    rules[ i ].color = tocolor( 255, 0, 0, 255 ) 
                    colorSet = i 
                    outputChatBox( tostring( colorSet))  
                end 
            end 
        end 
    end 
) 
  

Link to comment
  
rules = { } 
rulesInfo = {} 
colorSet = false 
showing = false 
currentText = "- Please select a menu! -" 
rules[ 'Server Staff' ] = {  
    acceptX = (screenW - 202) / 2 - 295, 
    acceptY = (screenH - 39) / 2 - 90.50, 
    acceptW = ((screenW - 202) / 2 - 295) + 152,  
    acceptH = ( (screenH - 39) / 2 - 90.50) + 30, 
    color = tocolor( 255, 255, 255, 255 ) 
} 
rules[ 'Server Rules' ] = { 
    acceptX = (screenW - 202) / 2 - 295, 
    acceptY = (screenH - 39) / 2 - 41.50,  
    acceptW = ((screenW - 202) / 2 - 295) + 152,   
    acceptH = ( (screenH - 39) / 2 - 41.50) + 29, 
    color = tocolor( 255, 255, 255, 255 ) 
} 
rules[ 'Server News' ]  = { 
    acceptX = (screenW - 202) / 2 - 295, 
    acceptY = (screenH - 39) / 2 + 56.50,  
    acceptW = ((screenW - 202) / 2 - 295) + 152,  
    acceptH = ( (screenH - 39) / 2 + 56.50) + 31,  
    color = tocolor( 255, 255, 255, 255 ) 
} 
rules[ 'Server Information' ] = { 
    acceptX = (screenW - 202) / 2 - 295, 
    acceptY = (screenH - 39) / 2 + 7.50, 
    acceptW = ((screenW - 202) / 2 - 295) + 218,  
    acceptH = ( (screenH - 39) / 2 + 7.50) + 29, 
    color = tocolor( 255, 255, 255, 255 ) 
} 
rules[ 'Server Player Count' ] = { 
    acceptX = (screenW - 202) / 2 - 295,  
    acceptY = (screenH - 39) / 2 + 105.50,  
    acceptW = ((screenW - 202) / 2 - 295) + 233,  
    acceptH = ( (screenH - 39) / 2 + 105.50) + 33,  
    color = tocolor( 255, 255, 255, 255 ) 
} 
  
  

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