Jump to content

Element Problem


Mossy

Recommended Posts

Posted

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.

anim_05f0aed7-5366-1024-9de0-f07365d770cc.gif
Posted

It says that the element does not exist at destroyElement?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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?

anim_05f0aed7-5366-1024-9de0-f07365d770cc.gif
Posted

The GUI creation is inside "onClientResourceStart" event, isn't it? if so, add the event inside that function as well.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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.

anim_05f0aed7-5366-1024-9de0-f07365d770cc.gif
Posted

Instead of placing the events outside the function where your GUI is created, place them inside, at the bottom of the function.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

I told you, the function where your GUI creation functions are.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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