Jump to content

table.insert


iPrestege

Recommended Posts

Hello,Guys ,

Will am working on my fucking script but i have problem here :

local table = {} 
addEventHandler("onClientResourceStart",resourceRoot, 
function ()  
    local node = xmlLoadFile ( "skins.xml" ) 
    if ( node ) then 
        local skins = 0 
        while ( xmlFindChild ( node, "skin", skins ) ) do 
            local skin = xmlFindChild ( node, "skin", skins ) 
            skins = skins + 1 
            local name = xmlNodeGetAttribute ( skin, "name" ) 
            local id = xmlNodeGetAttribute ( skin, "id" ) 
            table.insert( table, {name,id}) 
        end 
        xmlUnloadFile ( node ) 
    end 
    for k, v in ipairs ( table ) do 
        local row = guiGridListAddRow(GUIEditor.gridlist[1]) 
        guiGridListSetItemText(GUIEditor.gridlist[1], row, 1, tostring(v[2]), false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], row, 2, tostring(v[1]), false, false) 
        guiGridListSetItemColor(GUIEditor.gridlist[1], row, 1, 255, 0, 0)    
    end 
end  
) 

Debug :

EROR : Test/Client.lua:84: attempt to call field 'insert' ( nil value ) .

Regards Prestege .

Link to comment

You can see here i change it but the same error :

local MySkins = {} 
  
  
addEventHandler("onClientResourceStart",resourceRoot, 
function ()  
    local node = xmlLoadFile ( "skins.xml" ) 
    if ( node ) then 
        local skins = 0 
        while ( xmlFindChild ( node, "skin", skins ) ) do 
            local skin = xmlFindChild ( node, "skin", skins ) 
            skins = skins + 1 
            local name = xmlNodeGetAttribute ( skin, "name" ) 
            local id = xmlNodeGetAttribute ( skin, "id" ) 
             table.insert( MySkins, { name,id } ) 
        end 
        xmlUnloadFile ( node ) 
    end 
    for k, v in ipairs ( MySkins ) do 
        local row = guiGridListAddRow(GUIEditor.gridlist[1]) 
        guiGridListSetItemText(GUIEditor.gridlist[1], row, 1, tostring(v[2]), false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], row, 2, tostring(v[1]), false, false) 
        guiGridListSetItemColor(GUIEditor.gridlist[1], row, 1, 255, 0, 0)    
    end 
end  
) 
  
Link to comment

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