Jump to content

[Help]....


Recommended Posts

Posted

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

F4MZM4.gif

Guest Guest4401
Posted

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.

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

F4MZM4.gif

Posted

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
Posted

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

Posted
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]) 
  

F4MZM4.gif

Posted

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

Posted
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

F4MZM4.gif

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

F4MZM4.gif

Posted

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

Posted
Yes. Try it:
function DestroyWindow() 
    destroyElement(GUIEditor_Window[1]) 
    guiSetInputEnabled(false) 
    showCursor(false) 
end 

Thanks !!!!!!!!!!! it works !!! ^_^

F4MZM4.gif

Posted (edited)

Why you're using destroyElement() instead of guiSetVisible()?

Edited by Guest

Please do not PM me with scripting related question nor support, use the forums instead.

Posted

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

Posted
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 : )

F4MZM4.gif

Posted

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

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