Mossy Posted November 13, 2012 Share Posted November 13, 2012 Hey, I'm creating a UCP for my server and for some reason it's not defining the element. Here's a part of the script with the error: function outputMoney () triggerServerEvent("onPlayerAskMoney", localPlayer) destroyElement ( GUIEditor.button[4] ) end addEventHandler ( "onClientGUIClick", GUIEditor.button[4], outputMoney ) It says the 2nd argument's element returns nil. Here's a part of my script with the element: GUIEditor.button[4] = guiCreateButton(409, 359, 101, 43, "Free $100", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[4], "NormalTextColour", "FFAAAAAA") Any help? Thanks. Link to comment
Castillo Posted November 13, 2012 Share Posted November 13, 2012 It says that the element does not exist at destroyElement? Link to comment
Mossy Posted November 13, 2012 Author Share Posted November 13, 2012 No addEventHandler Apparently it says that the GUIEditor.button[4] is not an element, which I intended it to be. Should I rename the element to button4 so it configures it? Link to comment
Castillo Posted November 13, 2012 Share Posted November 13, 2012 The GUI creation is inside "onClientResourceStart" event, isn't it? if so, add the event inside that function as well. Link to comment
Mossy Posted November 13, 2012 Author Share Posted November 13, 2012 I have to go for tonight so I'll continue this tomorrow. Link to comment
Mossy Posted November 14, 2012 Author Share Posted November 14, 2012 You confused me a bit. Here's the full code: GUIEditor = { button = {}, label = {}, window = {}, } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(346, 214, 756, 511, "User Control Panel", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.label[1] = guiCreateLabel(52, 37, 640, 63, "Welcome!", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[1], "sa-gothic") guiLabelSetColor(GUIEditor.label[1], 74, 240, 86) guiLabelSetHorizontalAlign(GUIEditor.label[1], "center", false) GUIEditor.label[2] = guiCreateLabel(50, 122, 641, 116, "Welcome to Fly San Andreas! Right now you are viewing the incomplete UCP. Our server is not finished so just look \naround and see what we have for now!", false, GUIEditor.window[1]) guiLabelSetHorizontalAlign(GUIEditor.label[2], "center", false) GUIEditor.label[3] = guiCreateLabel(123, 252, 490, 35, "To get started type /work and follow the instructions!", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[3], "default-bold-small") guiLabelSetHorizontalAlign(GUIEditor.label[3], "center", false) GUIEditor.button[1] = guiCreateButton(14, 468, 79, 34, "Close", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA") GUIEditor.button[2] = guiCreateButton(224, 359, 101, 43, "News", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFAAAAAA") GUIEditor.button[4] = guiCreateButton(409, 359, 101, 43, "Free $100", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[4], "NormalTextColour", "FFAAAAAA") end ) function outputMoney () triggerServerEvent("onPlayerAskMoney", localPlayer) destroyElement ( GUIEditor.button[4] ) end addEventHandler ( "onClientGUIClick", GUIEditor.button[4], outputMoney ) function closeWindow () destroyElement ( GUIEditor.window[1] ) end addEventHandler ( "onClientGUIClick", GUIEditor.button[1], closeWindow ) Now what do I put where? Please be more specific. Link to comment
Castillo Posted November 14, 2012 Share Posted November 14, 2012 Instead of placing the events outside the function where your GUI is created, place them inside, at the bottom of the function. Link to comment
Mossy Posted November 14, 2012 Author Share Posted November 14, 2012 All of the events? And inside of where? Bottom of which function? I'm sorry, this is my first GUI Link to comment
Castillo Posted November 14, 2012 Share Posted November 14, 2012 I told you, the function where your GUI creation functions are. 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