Jump to content

HELP - Login panel


Norhy

Recommended Posts

Hi again. I've got another gui called wdwMenu. Now i created a combobox, but idk how to attach it to the gui wdwMenu. The code:

cmbTeam = guiCreateComboBox ( left, top, windowWidth,windowHeight, "Team", true ) 

Please how to attach the Combobox to the GUI? So i choose its positions in the menu ( bottom, corner etc.. )

Link to comment
Hi again. I've got another gui called wdwMenu. Now i created a combobox, but idk how to attach it to the gui wdwMenu. The code:
cmbTeam = guiCreateComboBox ( left, top, windowWidth,windowHeight, "Team", true ) 

Please how to attach the Combobox to the GUI? So i choose its positions in the menu ( bottom, corner etc.. )

Use the optional argument (parent)

parent: This is the parent that the GUI combobox is attached to. If the relative argument is true, sizes and positioning will be made relative to this parent. If the relative argument is false, positioning will be the number of offset pixels from the parent's origin. If no parent is passed, the parent will become the screen - causing positioning and sizing according to screen positioning.

cmbTeam = guiCreateComboBox(left, top, windowWidth,windowHeight, "Team", true, wdwMenu) 

Link to comment

Here, i got this code:

        comboTeam = guiCreateComboBox ( 0.20, 0.03, 0.25, 0.30, "Team", true, wdwMenu ) 
        guiComboBoxAddItem(comboTeam, "Police") 
        guiComboBoxAddItem(comboTeam, "Criminal") 
        guiComboBoxAddItem(comboTeam, "Civillian") 
        guiComboBoxAddItem(comboTeam, "Military") 
        guiComboBoxAddItem(comboTeam, "Staff") 

And i created a memo. Now i want, if someone clicks on the comboBoxItem for example: "Police", then in the memo will appear some text.. How to do that?

Link to comment
addEventHandler("onClientGUIClick",root,function() 
    if ( source == comboTeam  ) then 
        local item = guiComboBoxGetSelected(comboTeam) 
        local text = guiComboBoxGetItemText(comboTeam, item) 
        if ( tostring(text) and tostring(text) ~= "" ) then 
            if ( tostring(text) == "Police" ) then 
                guiSetText(Memo,"whatever ..") 
            end 
        end 
    end 
end ) 

Link to comment
addEventHandler ( "onClientGUIComboBoxAccepted", guiRoot, 
    function ( comboBox ) 
        if ( comboBox == comboTeam ) then 
            local item = guiComboBoxGetSelected ( comboBox ) 
            local text = guiComboBoxGetItemText ( comboBox, item ) 
            if ( tostring ( text ) and tostring ( text ) ~= "" ) then 
                if ( tostring ( text ) == "Police" ) then 
                    guiSetText ( Memo, "whatever .." ) 
                end 
            end 
        end 
    end 
) 

I'm guessing that you have "Memo" defined?

Link to comment

Sorry for doubleposting and wasting your time, but i got a another problem. The team comboBox is working. I created a another one, called "comboClass". Now, when they playes chooses the "Police" team, in the "comboClass" comboBox will be added a item called "Officer", but when i choose "Police" team again, another "Officer" item pops up.

How to make it, that when i choose the Police team several times, only 1 "Officer" class will appear?

Link to comment

Thank you. First i didn't knew, what you mean, but then i understood it.

    addEventHandler ( "onClientGUIComboBoxAccepted", guiRoot, 
        function ( comboBox ) 
            if ( comboBox == comboTeam  ) then 
                local item = guiComboBoxGetSelected ( comboBox ) 
                local text = guiComboBoxGetItemText ( comboBox, item ) 
                if ( tostring ( text ) and tostring ( text ) ~= "" ) then 
                    if ( tostring ( text ) == "Police" ) then 
                        guiSetText ( teamMemo, "This teams objective is to keep the streets clean and safe. They arrest criminals by hitting them with the nightstick. They main 'base' is at the LSPD." ) 
                        guiComboBoxClear ( comboClass )  
                        guiComboBoxAddItem(comboClass, "Officer") 
                    end 
                end 
            end 
        end 
    ) 

Link to comment

So. Another question :? . I don't understand the triggerClientEvent functions. So i need help. I have the gui wdwMenu, and i want it to appear when anyone logs in.

Login:

    function loginHandler(username,password,thePlayer) 
            local account = getAccount (username, password) 
            if account then 
                logIn(source, account, password) 
                triggerClientEvent(source,"HideGui",source) 
                triggerClientEvent ( "ShowGui", guiSetVisible(), wdwMenu, true ) 
            else 
                outputChatBox("Wrong username / password, try again.",source) 
            end 
    end 
    addEventHandler("submitLogin",root,loginHandler) 

I tried to do this:

function loginHandler(username,password,thePlayer) 
            local account = getAccount (username, password) 
            if account then 
                logIn(source, account, password) 
                triggerClientEvent(source,"HideGui",source) 
                triggerClientEvent ( "ShowGui", guiSetVisible(), wdwMenu, true ) 
            else 
                outputChatBox("Wrong username / password, try again.",source) 
            end 
    end 
    addEventHandler("submitLogin",root,loginHandler) 

[/lua]

But it doesn't work. I'm really a noob to triggering a event between Client or Server, so if someone would be so neat to explain me how to work with it, i would be glad.

Link to comment

Hello. Another problem need to be solved.

So, i will explain it: When i have select the team for e.g.: "Police" and the class "Officer", click on the button "Spawn" (btnSpawn) that then i will be spawned at LSPD.

Or: When i have select the team for e.g.: "Criminal" and the class "Robber", click on the button "Spawn" that then i will be spawned at the Unity Station.

How to make that pls?

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