Tete omar Posted May 18, 2012 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 ?.
Guest Guest4401 Posted May 18, 2012 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.
Tete omar Posted May 18, 2012 Author 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'
GTX Posted May 18, 2012 Posted May 18, 2012 Double-check if your button exists. Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS. Developer and owner of https://projectbea.st - Project Beast
Stanley Sathler Posted May 18, 2012 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. Software Engineer & Entrepreneur • Running Lustrel and VilarikA • Highly engaged on open source community
Tete omar Posted May 18, 2012 Author 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])
Stanley Sathler Posted May 18, 2012 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. Software Engineer & Entrepreneur • Running Lustrel and VilarikA • Highly engaged on open source community
Tete omar Posted May 18, 2012 Author 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
Tete omar Posted May 18, 2012 Author 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 ?
Stanley Sathler Posted May 18, 2012 Posted May 18, 2012 Yes. Try it: function DestroyWindow() destroyElement(GUIEditor_Window[1]) guiSetInputEnabled(false) showCursor(false) end Software Engineer & Entrepreneur • Running Lustrel and VilarikA • Highly engaged on open source community
Tete omar Posted May 18, 2012 Author Posted May 18, 2012 Yes. Try it: function DestroyWindow() destroyElement(GUIEditor_Window[1]) guiSetInputEnabled(false) showCursor(false) end Thanks !!!!!!!!!!! it works !!!
DNL291 Posted May 18, 2012 Posted May 18, 2012 (edited) Why you're using destroyElement() instead of guiSetVisible()? Edited May 18, 2012 by Guest Please do not PM me with scripting related question nor support, use the forums instead.
Stanley Sathler Posted May 18, 2012 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. Software Engineer & Entrepreneur • Running Lustrel and VilarikA • Highly engaged on open source community
Tete omar Posted May 19, 2012 Author 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 : )
Alpha Posted May 19, 2012 Posted May 19, 2012 There is nothing wrong with asking here, if you bring the code with you then it's totally fine. My Resources: [REL] Support System v1.0.2
Stanley Sathler Posted May 19, 2012 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. Software Engineer & Entrepreneur • Running Lustrel and VilarikA • Highly engaged on open source community
Jaysds1 Posted May 29, 2012 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? My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Alpha Posted May 29, 2012 Posted May 29, 2012 Check the latest posts. My Resources: [REL] Support System v1.0.2
Jaysds1 Posted May 30, 2012 Posted May 30, 2012 your welcome My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
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