Jump to content

[RESOLVED] Help with GUI


Victor214

Recommended Posts

I learned the basic of lua script, now i'm trying to learn the basic of GUI script, so I started to read at the wiki, I understand almost everything, but i have 2 questions about this GUI script (I copyed the wiki code, but i understood everything), 1 - Why it isn't working? 2 - getResourceRootElement(getThisResource()) <- this! Other thing that I didn't understood is where should I put addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) ?? PS - there is only the GUI, not the scripting of it.

script:

  
function GUI 
    local X = 0.375 
    local Y = 0.375 
    local altura = 0.50 
    local largura = 0.25 
    wdwLogin = guiCreateWindow(X, Y, Width, Height, "TBG - Painel de Login!", true) 
    X = 0.0825 
    Y = 0.2 
    altura = 0.25 
    largura = 0.25 
    guiCreateLabel(X, Y, Width, Height, "Login", true, wdwLogin) 
    Y = 0.5 
    guiCreateLabel(X, Y, Width, Height, "Senha", true, wdwLogin) 
    X = 0.415 
    Y = 0.2 
    altura = 0.5 
    largura = 0.15 
    edtUser = guiCreateEdit(X, Y, Width, Height, "Seu login aqui", true, wdwLogin) 
    Y = 0.5 
    edtPass = guiCreateEdit(X, Y, Width, Height, "Sua senha aqui", true, wdwLogin) 
    guiEditSetMaxLength(edtUser, 15) 
    guiEditSetMaxLength(edtPass, 20) 
    X = 0.415 
    Y = 0.7 
    Width = 0.25 
    Height = 0.2 
    btnLogin = guiCreateButton(X, Y, Width, Height, "Log In", true, wdwLogin) 
    guiSetVisible(wdwLogin, true) 
end 
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()),  
    function () 
    createLoginWindow() 
     outputChatBox("Bem vindo/a ao TBG - RealPlay!") 
     if (wdwLogin ~= nil) then 
            guiSetVisible(wdwLogin, true) 
        else 
        outputChatBox("Ocorreu um inesperado erro no carregamento no painel de Login, tente reconectar!") 
            end  
    showCursor(true) 
     guiSetInputEnabled(true) 
    end 
  
  

Edited by Guest
Link to comment

At the end of each function you need to add ()

function GUI () 

What are "Width" and "Height"?

local altura = 0.50 
    local largura = 0.25 
    wdwLogin = guiCreateWindow(X, Y, Width, Height, "TBG - Painel de Login!", true) 

altura and lagura im guessing are the Width and Height, so you need to change the 3rd line too:

    wdwLogin = guiCreateWindow(X, Y,altura,largura, "TBG - Painel de Login!", true) 

So the final code is:

  
function GUI () 
    local X = 0.375 
    local Y = 0.375 
    local altura = 0.50 
    local largura = 0.25 
    wdwLogin = guiCreateWindow(X, Y, Width, Height, "TBG - Painel de Login!", true) 
    X = 0.0825 
    Y = 0.2 
    altura = 0.25 
    largura = 0.25 
    guiCreateLabel(X, Y, Width, Height, "Login", true, wdwLogin) 
    Y = 0.5 
    guiCreateLabel(X, Y, Width, Height, "Senha", true, wdwLogin) 
    X = 0.415 
    Y = 0.2 
    altura = 0.5 
    largura = 0.15 
    edtUser = guiCreateEdit(X, Y, Width, Height, "Seu login aqui", true, wdwLogin) 
    Y = 0.5 
    edtPass = guiCreateEdit(X, Y, Width, Height, "Sua senha aqui", true, wdwLogin) 
    guiEditSetMaxLength(edtUser, 15) 
    guiEditSetMaxLength(edtPass, 20) 
    X = 0.415 
    Y = 0.7 
    Width = 0.25 
    Height = 0.2 
    btnLogin = guiCreateButton(X, Y, Width, Height, "Log In", true, wdwLogin) 
    guiSetVisible(wdwLogin, true) 
end 
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), 
    function () 
    createLoginWindow() 
     outputChatBox("Bem vindo/a ao TBG - RealPlay!") 
     if (wdwLogin ~= nil) then 
            guiSetVisible(wdwLogin, true) 
        else 
        outputChatBox("Ocorreu um inesperado erro no carregamento no painel de Login, tente reconectar!") 
            end 
    showCursor(true) 
     guiSetInputEnabled(true) 
    end 

Edited by Guest
Link to comment
Oh, Thanks xD

And sorry for my ignorance, this is my first GUI script :D

Edit : Oh, my brother wrote that, Yeah, Altura and Largura are WIdth and Heigth, i told him to translate to english but he didn't :P

Your not ignorant at all, your just asking a question :) but what Im glad to see is that your actually trying to learn LUA.

In the future when you get an error, login as admin in your server and type /debugscript 3 that will display a GUI that shows the errors on the script, post the errors here and then we can narrow down whats wrong.

Link to comment
Oh, Thanks xD

And sorry for my ignorance, this is my first GUI script :D

Edit : Oh, my brother wrote that, Yeah, Altura and Largura are WIdth and Heigth, i told him to translate to english but he didn't :P

Your not ignorant at all, your just asking a question :) but what Im glad to see is that your actually trying to learn LUA.

In the future when you get an error, login as admin in your server and type /debugscript 3 that will display a GUI that shows the errors on the script, post the errors here and then we can narrow down whats wrong.

Okay, i'll do that :D

I dont know if you know, but i'm StormFox, from the SAUR server :D

And Thanks for all your help, i really appreciate it :)

Link to comment

I know that i should put it at the end, put at the end i've already put

  
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource(),  
    function GUI1() 
    createLoginWindow() 
     outputChatBox("Bem vindo/a ao TBG - RealPlay!") 
     if (wdwLogin ~= nil) then 
            guiSetVisible(wdwLogin, true) 
        else 
        outputChatBox("Ocorreu um inesperado erro no carregamento no painel de Login, tente reconectar!") 
            end  
    showCursor(true) 
     guiSetInputEnabled(true) 
    end 
) 
  

I understood this other type to use addEventHandler, but the problem is how to put this code /\ and this "addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false)" at the same time =P

Link to comment
I know that i should put it at the end, put at the end i've already put
  
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource(),  
    function GUI1() 
    createLoginWindow() 
     outputChatBox("Bem vindo/a ao TBG - RealPlay!") 
     if (wdwLogin ~= nil) then 
            guiSetVisible(wdwLogin, true) 
        else 
        outputChatBox("Ocorreu um inesperado erro no carregamento no painel de Login, tente reconectar!") 
            end  
    showCursor(true) 
     guiSetInputEnabled(true) 
    end 
) 
  

I understood this other type to use addEventHandler, but the problem is how to put this code /\ and this "addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false)" at the same time =P

Ah I understand you now. This is proberly going to confuse you, but if its an onClientGUIClick and the GUI is inside a function, you put the Event inside of it like this:

addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource(),  
    function GUI1() 
    createLoginWindow() 
     outputChatBox("Bem vindo/a ao TBG - RealPlay!") 
-- BUTTON IS CREATED HERE OR WHATEVER ;3 
     if (wdwLogin ~= nil) then 
            guiSetVisible(wdwLogin, true) 
        else 
        outputChatBox("Ocorreu um inesperado erro no carregamento no painel de Login, tente reconectar!") 
            end  
    showCursor(true) 
     guiSetInputEnabled(true) 
addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) 
    end 
) 

Then you need to make a function called clientSubmitLogin which has all the stuff the button does when its clicked.

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