justn Posted March 22, 2014 Share Posted March 22, 2014 (edited) So yeah, I have a combobox (language chat ) , and i wanna know how to like, if the player clicks an item from the combobox then it will bindKey 'L' in chat and the language. Edited March 23, 2014 by Guest Link to comment
cheez3d Posted March 22, 2014 Share Posted March 22, 2014 local language_handler = function(_,language,...) local text = table.concat({...}," ") outputChatBox("["..language.."] "..getPlayerName(localPlayer)..": "..text,root,255,255,255,true) end addCommandHandler("language",language_handler) bindKey("l","down","chatbox","language",guiComboBoxGetItemText(guiComboBoxGetSelected(--[[your_combo_box]]))) Link to comment
justn Posted March 22, 2014 Author Share Posted March 22, 2014 So you're saying this? sx,sy = guiGetScreenSize() lp = getLocalPlayer() mr = math.random(1,2) LanguageWindow = guiCreateComboBox(328, 229, 403, 435, "Please choose your language..", false) guiSetVisible(LanguageWindow,false) guiSetFont(LanguageWindow, "default-bold-small") guiSetProperty(LanguageWindow, "NormalEditTextColour", "FF170800") guiComboBoxAddItem(LanguageWindow, "Please choose your language..") guiComboBoxAddItem(LanguageWindow, "Arabic") guiComboBoxAddItem(LanguageWindow, "French") guiComboBoxAddItem(LanguageWindow, "Spanish") local language_handler = function(player,_,language,...) local text = table.concat({...}," ") outputChatBox("["..language.."] "..getPlayerName(player)..": "..text,root,255,255,255,true) end addCommandHandler("language",language_handler) bindKey("l","down","chatbox","language",guiComboBoxGetItemText(guiComboBoxGetSelected(LanguageWindow))) Link to comment
JR10 Posted March 22, 2014 Share Posted March 22, 2014 Not exactly, this way it will always return the first item which is the 'Please choose your language..'. You need it to change when the combobox is changed. You can use the onClientGUIComboBoxAccepted: addEventHandler('onClientGUIComboBoxAccepted', LanguageWindow, function(combo) local item = guiComboBoxGetSelected (combo) if (item == 0) then return end local text = tostring (guiComboBoxGetItemText(combo, item)) unbindKey('l', 'down', 'chatbox') bindKey('l', 'down', 'chatbox', 'language', text) end) Link to comment
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