Jump to content

[Help]....


Recommended Posts

Guest Guest4401

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
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

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
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
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

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
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
  • 2 weeks later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...