Norhy Posted August 28, 2012 Author Posted August 28, 2012 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.. )
TAPL Posted August 28, 2012 Posted August 28, 2012 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)
Norhy Posted August 28, 2012 Author Posted August 28, 2012 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?
Al3grab Posted August 28, 2012 Posted August 28, 2012 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 )
Castillo Posted August 28, 2012 Posted August 28, 2012 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?
Norhy Posted August 28, 2012 Author Posted August 28, 2012 teamMemo = guiCreateMemo( 10, 50, 500, 150, "", false, wdwMenu ) Yes, i have. Thank you for the help.
Castillo Posted August 28, 2012 Posted August 28, 2012 You must change the guiSetText "Memo" to "teamMemo".
Norhy Posted August 28, 2012 Author Posted August 28, 2012 You must change the guiSetText "Memo" to "teamMemo". I did don't worry
Norhy Posted August 28, 2012 Author Posted August 28, 2012 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?
Castillo Posted August 28, 2012 Posted August 28, 2012 Clear it first with: https://wiki.multitheftauto.com/wiki/GuiComboBoxClear
Norhy Posted August 28, 2012 Author Posted August 28, 2012 Clear it first with: https://wiki.multitheftauto.com/wiki/GuiComboBoxClear 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 )
Norhy Posted August 28, 2012 Author Posted August 28, 2012 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.
Norhy Posted August 29, 2012 Author Posted August 29, 2012 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?
Norhy Posted August 29, 2012 Author Posted August 29, 2012 triggerServerEvent spawnPlayer Could you help me with this, per Skype? Because idk what to do..
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now