Jump to content

Create GUI on Table!


undefined

Recommended Posts

Posted

Hi guys. Im tryed this but it's not on the skillWindow.

Image:

GbVXvv.png

Code:

data = { 
    background = { 
        {10, 54, 550, 41, ":test/Adsiz.png", false, skillWindow}, 
        {10, 105, 550, 41, ":test/Adsiz.png", false, skillWindow}, 
        {10, 156, 550, 41, ":test/Adsiz.png", false, skillWindow}, 
        {10, 207, 550, 41, ":test/Adsiz.png", false, skillWindow}, 
        {10, 258, 550, 41, ":test/Adsiz.png", false, skillWindow}, 
        {10, 309, 550, 41, ":test/Adsiz.png", false, skillWindow}, 
        {10, 360, 550, 41, ":test/Adsiz.png", false, skillWindow} 
    } 
} 
  
local back = {} 
addEventHandler("onClientResourceStart", resourceRoot, function() 
    skillWindow = guiCreateWindow(369, 143, 570, 418, "test", false) 
    guiWindowSetSizable(skillWindow, false) 
    guiSetAlpha(skillWindow, 0.85) 
    for k, v in pairs(data.background) do 
        back[k] = guiCreateStaticImage(unpack(v)) 
    end 
end) 

Where is the problem?

Posted
data = { 
    background = { 
        {10, 54, 550, 41, ":test/Adsiz.png", false, skillWindow}, 
        {10, 105, 550, 41, ":test/Adsiz.png", false, skillWindow}, 
        {10, 156, 550, 41, ":test/Adsiz.png", false, skillWindow}, 
        {10, 207, 550, 41, ":test/Adsiz.png", false, skillWindow}, 
        {10, 258, 550, 41, ":test/Adsiz.png", false, skillWindow}, 
        {10, 309, 550, 41, ":test/Adsiz.png", false, skillWindow}, 
        {10, 360, 550, 41, ":test/Adsiz.png", false, skillWindow} 
    } 
} 
  
local back = {} 
addEventHandler("onClientResourceStart", resourceRoot, function() 
    skillWindow = guiCreateWindow(369, 143, 570, 418, "test", false) 
    guiWindowSetSizable(skillWindow, false) 
    guiSetAlpha(skillWindow, 0.85) 
    for k, v in ipairs(data.background) do 
        back[k] = guiCreateStaticImage(unpack(v)) 
    end 
end) 

rsilex.png.0e6ad382b3fdc3cbe6390e3e847572c9.png
Posted (edited)

Because skillWindow is returning nil in the table you created.

Try this:

data = {} 
  
local back = {} 
addEventHandler("onClientResourceStart", resourceRoot, function() 
    skillWindow = guiCreateWindow(369, 143, 570, 418, "test", false) 
    data.background = { 
        {10, 54, 550, 41, ":test/Adsiz.png", false, skillWindow}, 
        {10, 105, 550, 41, ":test/Adsiz.png", false, skillWindow}, 
        {10, 156, 550, 41, ":test/Adsiz.png", false, skillWindow}, 
        {10, 207, 550, 41, ":test/Adsiz.png", false, skillWindow}, 
        {10, 258, 550, 41, ":test/Adsiz.png", false, skillWindow}, 
        {10, 309, 550, 41, ":test/Adsiz.png", false, skillWindow}, 
        {10, 360, 550, 41, ":test/Adsiz.png", false, skillWindow} 
    } 
    guiWindowSetSizable(skillWindow, false) 
    guiSetAlpha(skillWindow, 0.85) 
    for i, v in ipairs(data.background) do 
        back[i] = guiCreateStaticImage(unpack(v)) 
    end 
end) 

data = { 
    background = { 
        {10, 54, 550, 41, ":test/Adsiz.png", false, skillWindow}, 
        {10, 105, 550, 41, ":test/Adsiz.png", false, skillWindow}, 
        {10, 156, 550, 41, ":test/Adsiz.png", false, skillWindow}, 
        {10, 207, 550, 41, ":test/Adsiz.png", false, skillWindow}, 
        {10, 258, 550, 41, ":test/Adsiz.png", false, skillWindow}, 
        {10, 309, 550, 41, ":test/Adsiz.png", false, skillWindow}, 
        {10, 360, 550, 41, ":test/Adsiz.png", false, skillWindow} 
    } 
} 
  
local back = {} 
addEventHandler("onClientResourceStart", resourceRoot, function() 
    skillWindow = guiCreateWindow(369, 143, 570, 418, "test", false) 
    guiWindowSetSizable(skillWindow, false) 
    guiSetAlpha(skillWindow, 0.85) 
    for k, v in ipairs(data.background) do 
        back[k] = guiCreateStaticImage(unpack(v)) 
    end 
end) 

Well, from what i see it looks the same code that AbaZaSiRiN00 posted.

Edited by Guest

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

Posted

I just tested my code and it works perfectly has nothing to do with "skillWindow" only need need change pairs -- > ipairs because the table what he try to loop have indexes

kgHPlfY.png

rsilex.png.0e6ad382b3fdc3cbe6390e3e847572c9.png
Posted
I just tested my code and it works perfectly has nothing to do with "skillWindow" only need need change pairs -- > ipairs because the table what he try to loop have indexes

kgHPlfY.png

No, the images is still without a parent element since it's being created out of the window, which means that skillWindow is returning nil.

No, they're different. He has changed "pairs" by "ipairs".

Ah, didn't realize it.

By the way, i've tested my code and it works fine.

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

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