Jump to content

[SOLVED] HELP! XML ...


SpecT

Recommended Posts

Serverside scripts are loading much faster than clientside script. You are triggering event which doesn't really exist. Do like that:

s-side

addEvent ( "requestUpdating", true ); 
function updateSongs ( ) 
    local file = xmlLoadFile ( "songs.xml" ) 
    if ( file ) then 
        triggerClientEvent ( source, "onLoadTable", source, xmlNodeGetChildren ( file ) ) 
    end 
    xmlUnloadFile ( file ) 
end 
addEventHandler ( "requestUpdating", root, updateSongs ) 

c-side

songList = { } 
  
addEventHandler ( "onClientResourceStart", resourceRoot, 
    function ( ) 
        triggerServerEvent ( "requestUpdating", localPlayer ); 
    end 
); 
  
function loadTable ( table ) 
    if ( type ( table ) == "table" ) then 
        for _, v in pairs ( table ) do 
            local name, length, played = xmlNodeGetAttribute ( v, "name" ), xmlNodeGetAttribute ( v, "length" ), tonumber ( xmlNodeGetAttribute ( v, "played" )) 
            songList[name] = {length, played} 
        end 
    end 
end 
addEvent ( "onLoadTable", true ) 
addEventHandler ( "onLoadTable", root, loadTable ) 

The gridlist is empty ... no errors.

Link to comment
  • Replies 66
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Past your code with loading items to gridlist.
function loadSongsInGridlist() 
    for name, v in pairs ( songList ) do 
        table.insert(musicStore.songName,name) 
        table.insert(musicStore.songCache,name) 
    end 
end 

(If you want to know: I need the songCache for search function)

Link to comment

Add "loadSongsInGridlist()" line. Like that.

function loadTable ( table ) 
    if ( type ( table ) == "table" ) then 
        for _, v in pairs ( table ) do 
            local name, length, played = xmlNodeGetAttribute ( v, "name" ), xmlNodeGetAttribute ( v, "length" ), tonumber ( xmlNodeGetAttribute ( v, "played" )) 
            songList[name] = {length, played} 
        end 
        loadSongsInGridlist(); 
    end 
end 

Link to comment
Add "loadSongsInGridlist()" line. Like that.
function loadTable ( table ) 
    if ( type ( table ) == "table" ) then 
        for _, v in pairs ( table ) do 
            local name, length, played = xmlNodeGetAttribute ( v, "name" ), xmlNodeGetAttribute ( v, "length" ), tonumber ( xmlNodeGetAttribute ( v, "played" )) 
            songList[name] = {length, played} 
        end 
        loadSongsInGridlist(); 
    end 
end 

Already tried that ... still nothing in the gridlist. Lel :roll:

Link to comment
function loadTable ( table ) 
    if ( type ( table ) == "table" ) then 
        for _, v in pairs ( table ) do 
            local name, length, played = xmlNodeGetAttribute ( v, "name" ), xmlNodeGetAttribute ( v, "length" ), tonumber ( xmlNodeGetAttribute ( v, "played" )) 
            songList[name] = {length, played} 
            outputChatBox ( name ); 
        end 
        loadSongsInGridlist(); 
    end 
end 

Check if name shows up on chatbox.

Link to comment
function loadTable ( table ) 
    if ( type ( table ) == "table" ) then 
        for _, v in pairs ( table ) do 
            local name, length, played = xmlNodeGetAttribute ( v, "name" ), xmlNodeGetAttribute ( v, "length" ), tonumber ( xmlNodeGetAttribute ( v, "played" )) 
            songList[name] = {length, played} 
            outputChatBox ( name ); 
        end 
        loadSongsInGridlist(); 
    end 
end 

Check if name shows up on chatbox.

It doesn't.

Link to comment
addEvent ( "requestUpdating", true ); 
function updateSongs ( ) 
    local file = xmlLoadFile ( "songs.xml" ) 
    if ( file ) then 
        local child = xmlNodeGetChildren ( file ) 
        outputChatBox ( type ( child ) ); 
        triggerClientEvent ( source, "onLoadTable", source, child ) 
    end 
    xmlUnloadFile ( file ) 
end 
addEventHandler ( "requestUpdating", root, updateSongs ) 

Check what it outputs on chat.

Link to comment
addEvent ( "requestUpdating", true ); 
function updateSongs ( ) 
    local file = xmlLoadFile ( "songs.xml" ) 
    if ( file ) then 
        local child = xmlNodeGetChildren ( file ) 
        outputChatBox ( type ( child ) ); 
        triggerClientEvent ( source, "onLoadTable", source, child ) 
    end 
    xmlUnloadFile ( file ) 
end 
addEventHandler ( "requestUpdating", root, updateSongs ) 

Check what it outputs on chat.

It outputs a message: "table"

Link to comment

Try debugging it.

function loadTable ( table ) 
    outputChatBox ( "1" ) 
    if ( type ( table ) == "table" ) then 
        outputChatBox ( "2" ) 
        for _, v in pairs ( table ) do 
            outputChatBox ( "3" ) 
            local name, length, played = xmlNodeGetAttribute ( v, "name" ), xmlNodeGetAttribute ( v, "length" ), tonumber ( xmlNodeGetAttribute ( v, "played" )) 
            songList[name] = {length, played} 
            outputChatBox ( name ); 
        end 
        loadSongsInGridlist(); 
    end 
end 

How many numbers will be on chat?

Link to comment
Try debugging it.
function loadTable ( table ) 
    outputChatBox ( "1" ) 
    if ( type ( table ) == "table" ) then 
        outputChatBox ( "2" ) 
        for _, v in pairs ( table ) do 
            outputChatBox ( "3" ) 
            local name, length, played = xmlNodeGetAttribute ( v, "name" ), xmlNodeGetAttribute ( v, "length" ), tonumber ( xmlNodeGetAttribute ( v, "played" )) 
            songList[name] = {length, played} 
            outputChatBox ( name ); 
        end 
        loadSongsInGridlist(); 
    end 
end 

How many numbers will be on chat?

Got 1 and 2.

Link to comment

I have and idea tho.

s-side

addEvent ( "requestUpdating", true ); 
function updateSongs ( ) 
    local file = xmlLoadFile ( "songs.xml" ) 
    if ( file ) then 
        local t = { }; 
        for _, v in pairs ( xmlNodeGetChildren ( file ) ) do 
            local name, length, played = xmlNodeGetAttribute ( v, "name" ), xmlNodeGetAttribute ( v, "length" ), tonumber ( xmlNodeGetAttribute ( v, "played" )) 
            t[name] = {length, played} 
        end 
        triggerClientEvent ( source, "onLoadTable", source, t ); 
    end 
    xmlUnloadFile ( file ) 
end 
addEventHandler ( "requestUpdating", root, updateSongs ) 

c-side

addEventHandler ( "onClientResourceStart", resourceRoot, 
    function ( ) 
        triggerServerEvent ( "requestUpdating", localPlayer ); 
    end 
); 
  
function loadTable ( table ) 
    if ( type ( table ) == "table" ) then 
        songList = table; 
        loadSongsInGridlist(); 
    end 
end 
addEvent ( "onLoadTable", true ) 
addEventHandler ( "onLoadTable", root, loadTable ) 

Link to comment

Got errors on the server side:

Bad argument @ 'xmlNodeGetAttribute' [Expected xml-node at argument 1, got function]

EDIT: On the

local name, length, played = xmlNodeGetAttribute ( v, "name" ), xmlNodeGetAttribute ( v, "length" ), tonumber ( xmlNodeGetAttribute ( v, "played" ))

@I'm sorry dude for the wasted time ... :cry:

Edited by Guest
Link to comment
addEvent ( "requestUpdating", true ); 
function updateSongs ( ) 
    local file = xmlLoadFile ( "songs.xml" ) 
    if ( file ) then 
        local t = { }; 
        for _, data in pairs ( xmlNodeGetChildren ( file ) ) do 
            local name, length, played = xmlNodeGetAttribute ( data, "name" ), xmlNodeGetAttribute ( data, "length" ), tonumber ( xmlNodeGetAttribute ( data, "played" )) 
            t[name] = {length, played} 
        end 
        triggerClientEvent ( source, "onLoadTable", source, t ); 
    end 
    xmlUnloadFile ( file ) 
end 
addEventHandler ( "requestUpdating", root, updateSongs ) 

Has to work, lel.

Link to comment
addEvent ( "requestUpdating", true ); 
function updateSongs ( ) 
    local file = xmlLoadFile ( "songs.xml" ) 
    if ( file ) then 
        local t = { }; 
        for _, data in pairs ( xmlNodeGetChildren ( file ) ) do 
            local name, length, played = xmlNodeGetAttribute ( data, "name" ), xmlNodeGetAttribute ( data, "length" ), tonumber ( xmlNodeGetAttribute ( data, "played" )) 
            t[name] = {length, played} 
        end 
        triggerClientEvent ( source, "onLoadTable", source, t ); 
    end 
    xmlUnloadFile ( file ) 
end 
addEventHandler ( "requestUpdating", root, updateSongs ) 

Has to work, lel.

Oh lol lol lol lol and LOL.

Finally it worked! Everything works now - length and played time!

LOVE YA MATE !!!

And again I'm sorry for the time you wasted on this ... :/

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