Jump to content

[HELP] Gui creating each time button click


..:D&G:..

Recommended Posts

Posted

Hello guys, I got some problems with my login script. I made the buttons with labels, and when I click a label, I need to destroy the old gui elements, and create new ones, the problem it that if I click the label 2 or 3 times, it creates the same elements 2 or 3 times on top of each other, and when I click another button, only the first elements destroy, but the rest remain visible.

addEventHandler('onClientGUIClick', getRootElement(), 
function(button, state, absoluteX, absoluteY) 
    if(source == bInregistrare)then 
        if(button == 'left') then 
            guiSetVisible (lLogUsername, false) 
            guiSetVisible (lLogUsernameNote, false) 
            guiSetVisible (tLogUsername, false)  
            guiSetVisible (lLogPassword, false)  
            guiSetVisible (tLogPassword, false)  
            guiSetVisible (chkRemember, false)  
            guiSetVisible (bLogin, false)  
            guiSetVisible (bTitlu, false)  
            guiSetVisible (lText, false)  
            guiSetVisible (lTitlu, false)  
            guiSetVisible (bText, false)  
  
            lRegUsername = guiCreateLabel(367, 290, 93, 15, "Username:", false, windowMain) 
            guiSetFont(lRegUsername, "default-bold-small") 
             
            lRegUsernameNote = guiCreateStaticImage(569, 377, 76, 30, ":guieditor/images/examples/fereastra6.png", false, windowMain)  
            guiSetAlpha(lRegUsernameNote, 0.60) 
             
            tRegUsername = guiCreateEdit(460, 290, 185, 19, "", false, windowMain)  
            guiEditSetMaxLength(tRegUsername, 16) 
         
            lRegPassword = guiCreateLabel(417, 319, 43, 15, "Password:", false, windowMain)  
            guiSetFont(lRegPassword, "default-bold-small") 
  
            tRegPassword = guiCreateEdit(460, 319, 185, 19, "", false, windowMain)  
            guiEditSetMasked(tRegPassword, true) 
            guiEditSetMaxLength(tRegPassword, 29) 
  
            lRegPassword2 = guiCreateLabel(376, 348, 84, 15, "Repeat Password:", false, windowMain)  
            guiSetFont(lRegPassword2, "default-bold-small") 
  
            tRegPassword2 = guiCreateEdit(460, 348, 185, 19, "", false, windowMain)  
            guiEditSetMasked(tRegPassword2, true) 
            guiEditSetMaxLength(tRegPassword2, 29) 
  
            bRegister = guiCreateLabel(0, 0, 76, 30, "Register", false, lRegUsernameNote) 
            guiSetFont(bRegister, "default-bold-small") 
            guiLabelSetHorizontalAlign(bRegister, "center", false) 
            guiLabelSetVerticalAlign(bRegister, "center") 
            addEventHandler("onClientGUIClick", bRegister, registerAccount, false) 
         end 
    end 
end) 

Any ideas?

Posted

I know, but how do I do, so the labels will not be created as many times as I click the button? I want them to be created only once, even if I click the buton twice

Posted

You shouldn't create the elements on each click. You should create it once and use guiSetVisible to show/hide it.

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