Tete omar Posted May 18, 2012 Share Posted May 18, 2012 How do i put destroyElement in GUIEditor_Button[2] = guiCreateButton(155,251,69,30,"Exit",false,GUIEditor_Window[1]) is that an argument or something ?. Link to comment
Guest Guest4401 Posted May 18, 2012 Share Posted May 18, 2012 guiCreateButton returns an element, so yes GUIEditor_Button[2] is an element after its created. destroyElement is used to destroy an element and to destroy it, destroyElement(GUIEditor_Button[2]) The button will no longer exist after its destroyed. Link to comment
Tete omar Posted May 18, 2012 Author Share Posted May 18, 2012 guiCreateButton returns an element, so yes GUIEditor_Button[2] is an element after its created.destroyElement is used to destroy an element and to destroy it, destroyElement(GUIEditor_Button[2]) The button will no longer exist after its destroyed. Bad argument @ 'destroyElement' Link to comment
GTX Posted May 18, 2012 Share Posted May 18, 2012 Double-check if your button exists. Link to comment
Stanley Sathler Posted May 18, 2012 Share Posted May 18, 2012 Wait... do you wanna call the destroyElement() (for destroy the window) when the user click on button? If yes: function CreateGUIWindow() GUIEditor_Window[1] = guiCreateWindow(100, 100, 100, "My window title", false) GUIEditor_Button[2] = guiCreateButton(155,251,30,"Exit",false,GUIEditor_Window[1]) -- You must call the function using the "onClientGUIClick" event. addEventHandler("onClientGUIClick", GUIEditor_Button[2], DestroyWindow, false) end addEventHandler("onClientResourceStart", getRootElement(), CreateGUIWindow) function DestroyWindow() destroyElement(GUIEditor_Window[1]) end Obs: the code contain some erros purposely. You must read it and understand how it works. Link to comment
Tete omar Posted May 18, 2012 Author Share Posted May 18, 2012 Wait... do you wanna call the destroyElement() (for destroy the window) when the user click on button? If yes: function CreateGUIWindow() GUIEditor_Window[1] = guiCreateWindow(100, 100, 100, "My window title", false) GUIEditor_Button[2] = guiCreateButton(155,251,30,"Exit",false,GUIEditor_Window[1]) -- You must call the function using the "onClientGUIClick" event. addEventHandler("onClientGUIClick", GUIEditor_Button[2], DestroyWindow, false) end addEventHandler("onClientResourceStart", getRootElement(), CreateGUIWindow) function DestroyWindow() destroyElement(GUIEditor_Window[1]) end Obs: the code contain some erros purposely. You must read it and understand how it works. Here's the script local Marker = createMarker ( 1007.4000244141, -2302.6999511719, 12.10000038147, "cylinder", 1.29999995, 255, 0, 0, 255 ) addEventHandler('onClientMarkerHit', Marker, function (hitPlayer) if (hitPlayer == localPlayer) then guiSetVisible(GUIEditor_Window[1], true) showCursor(true) end end) GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Image = {} GUIEditor_Window[1] = guiCreateWindow(502,268,480,290,"Buy Ticket",false) GUIEditor_Image[1] = guiCreateStaticImage(240,20,229,261,"images/space.png",false,GUIEditor_Window[1]) GUIEditor_Button[1] = guiCreateButton(9,251,91,30,"Buy Ticket",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(155,251,69,30,"Exit",false,GUIEditor_Window[1]) GUIEditor_Memo[1] = guiCreateMemo(15,20,219,221,"=====|PlanetsTrip|=====\nWelcome to the\" Planets trip\", the moon trip is wonderful trip full of mystery stuff and nice gravitation,You'll find the absolute fun but try to find fun enough \nbecause time is only 10 minutes you will find above signs should find it in different areas, each one under 5k have a nice time\n====|Tickets|====\nMoon 50,000$\nMars 64,000$\nVenus 54,000$\nSaturn 75,000$\nMercury 35,000$=====|PlanetsTrip|====",false,GUIEditor_Window[1]) Link to comment
Stanley Sathler Posted May 18, 2012 Share Posted May 18, 2012 I asked if you wanna close the Window when the player click on Button. I'm right? If yes, you must implement my code in your. I will not do it for you. Link to comment
Tete omar Posted May 18, 2012 Author Share Posted May 18, 2012 I asked if you wanna close the Window when the player click on Button. I'm right? If yes, you must implement my code in your. I will not do it for you. Thx Link to comment
Tete omar Posted May 18, 2012 Author Share Posted May 18, 2012 I asked if you wanna close the Window when the player click on Button. I'm right? If yes, you must implement my code in your. I will not do it for you. Bro i put your code like that local Marker = createMarker ( 1007.4000244141, -2302.6999511719, 12.10000038147, "cylinder", 1.29999995, 255, 0, 0, 255 ) addEventHandler('onClientMarkerHit', Marker, function (hitPlayer) if (hitPlayer == localPlayer) then guiSetVisible(GUIEditor_Window[1], true) showCursor(true) end end) function CreateGUIWindow() GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Image = {} GUIEditor_Window[1] = guiCreateWindow(502,268,480,290,"Buy Ticket",false) GUIEditor_Image[1] = guiCreateStaticImage(240,20,229,261,"images/space.png",false,GUIEditor_Window[1]) GUIEditor_Button[1] = guiCreateButton(9,251,91,30,"Buy Ticket",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(155,251,69,30,"Exit",false,GUIEditor_Window[1]) GUIEditor_Memo[1] = guiCreateMemo(15,20,219,221,"=====|PlanetsTrip|=====\nWelcome to the\" Planets trip\", the moon trip is wonderful trip full of mystery stuff and nice gravitation,You'll find the absolute fun but try to find fun enough \nbecause time is only 10 minutes you will find above signs should find it in different areas, each one under 5k have a nice time\n====|Tickets|====\nMoon 50,000$\nMars 64,000$\nVenus 54,000$\nSaturn 75,000$\nMercury 35,000$=====|PlanetsTrip|====",false,GUIEditor_Window[1]) addEventHandler("onClientGUIClick", GUIEditor_Button[2], DestroyWindow, false) end addEventHandler("onClientResourceStart", getRootElement(), CreateGUIWindow) guiSetVisible(GUIEditor_Window[1], false) function DestroyWindow() destroyElement(GUIEditor_Window[1]) end the exit window works but when the window disappear i can't move .. is that guiSetVisible ? Link to comment
Stanley Sathler Posted May 18, 2012 Share Posted May 18, 2012 Yes. Try it: function DestroyWindow() destroyElement(GUIEditor_Window[1]) guiSetInputEnabled(false) showCursor(false) end Link to comment
Tete omar Posted May 18, 2012 Author Share Posted May 18, 2012 Yes. Try it: function DestroyWindow() destroyElement(GUIEditor_Window[1]) guiSetInputEnabled(false) showCursor(false) end Thanks !!!!!!!!!!! it works !!! Link to comment
DNL291 Posted May 18, 2012 Share Posted May 18, 2012 (edited) Why you're using destroyElement() instead of guiSetVisible()? Edited May 18, 2012 by Guest Link to comment
Stanley Sathler Posted May 18, 2012 Share Posted May 18, 2012 Teteomar, listen to DNL. The better way to work with GUI's is: - First, create all elements that you want (windows, buttons, labels, and more). Create a function to store it. - Set all elements invisible (using guiSetVisible() function) - Attach the function to event "onClientResourceStart". So, when the player start the resource, all GUI elements will be created, but will be invisible. - Second, create another function. In this function, just set all elements visible (using, again, guiSetVisible()). - Attach this function to event "onClientMarkerHit". So, when the player hit a marker, all elements will be visible. If you do this steps, the GUI will be created just one time. And always you need it, the elements will just be visible. If you do like you did in the first code, the elements will be created everytime that player hit a marker. Link to comment
Tete omar Posted May 19, 2012 Author Share Posted May 19, 2012 Teteomar, listen to DNL. The better way to work with GUI's is:- First, create all elements that you want (windows, buttons, labels, and more). Create a function to store it. - Set all elements invisible (using guiSetVisible() function) - Attach the function to event "onClientResourceStart". So, when the player start the resource, all GUI elements will be created, but will be invisible. - Second, create another function. In this function, just set all elements visible (using, again, guiSetVisible()). - Attach this function to event "onClientMarkerHit". So, when the player hit a marker, all elements will be visible. If you do this steps, the GUI will be created just one time. And always you need it, the elements will just be visible. If you do like you did in the first code, the elements will be created everytime that player hit a marker. Nice.. i 'll test my self in one and i 'll never ask here .. i 'll do it with my self and thanks : ) Link to comment
Alpha Posted May 19, 2012 Share Posted May 19, 2012 There is nothing wrong with asking here, if you bring the code with you then it's totally fine. Link to comment
Stanley Sathler Posted May 19, 2012 Share Posted May 19, 2012 Yes, I agree with Alpha, Teteomar. You can ask here... but when do it, you must show us your code and show us that you tried. Some members come here and wanna a ready script, and it is very, very uncomfortable. Link to comment
Tete omar Posted May 29, 2012 Author Share Posted May 29, 2012 No i'm not one of these peoples Link to comment
Jaysds1 Posted May 29, 2012 Share Posted May 29, 2012 Is there any problem here? Is the problem done or does it still occur? if it still occurs, what's the problem? Link to comment
Tete omar Posted May 30, 2012 Author Share Posted May 30, 2012 No problem thanks Jaysds 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