Hey guys,
I'm new in scripting for mta but i have some know how in LUA.
Only one little function in my script is not working well.
I created a gui with a ComboBox and a Button.
In the ComboBox i added the item 'Admiral'.
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()),
function ()
wdwVeh = guiCreateWindow(32, 245, 264, 495, "Auto aus wählen:", false)
cbmVeh = guiCreateComboBox(427, 80, 0, 15, "", false, wdwVeh)
cbmVeh2 = guiCreateComboBox(10, 24, 244, 423, "", false, wdwVeh)
guiComboBoxAddItem(cbmVeh2, "Admiral")
btnVeh = guiCreateButton(172, 457, 82, 28, "Wählen", false, wdwVeh)
guiSetVisible(wdwVeh, false)
addEventHandler("onClientGUIClick", btnVeh, chooseVehicle, button )
end
)
The gui is working. Everything shows up when i press 'x' (bindkey).
But i have added a function to the ButtonClick event which is called "chooseVehicle"
function chooseVehicle( button )
local text = guiComboBoxGetSelected(cbmVeh2)
if text == "Admiral" then
triggerServerEvent ( "cbmVeh", localPlayer)
else
outputChatBox("It's not working :C")
end
showCursor(false)
guiSetVisible(wdwVeh, false)
end
so and in this part of my code i have a problem.
if the selected item is "admiral" then I want to spawn an Admiral but it ever shows the 'It's not working :C' but i don't know why.
If I try this:
outputChatBox(''..text..'')
it shows the Admiral in the chat.
So is someone there who knows where the problem is?
And sorry for my bad english i'm German
Greets