SpecT Posted April 8, 2015 Author Posted April 8, 2015 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.
SpecT Posted April 8, 2015 Author Posted April 8, 2015 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)
WhoAmI Posted April 8, 2015 Posted April 8, 2015 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
SpecT Posted April 8, 2015 Author Posted April 8, 2015 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
WhoAmI Posted April 8, 2015 Posted April 8, 2015 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.
SpecT Posted April 8, 2015 Author Posted April 8, 2015 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.
WhoAmI Posted April 8, 2015 Posted April 8, 2015 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.
SpecT Posted April 8, 2015 Author Posted April 8, 2015 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"
WhoAmI Posted April 8, 2015 Posted April 8, 2015 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?
SpecT Posted April 8, 2015 Author Posted April 8, 2015 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.
WhoAmI Posted April 8, 2015 Posted April 8, 2015 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 )
SpecT Posted April 8, 2015 Author Posted April 8, 2015 (edited) 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 ... Edited April 8, 2015 by Guest
WhoAmI Posted April 8, 2015 Posted April 8, 2015 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.
SpecT Posted April 8, 2015 Author Posted April 8, 2015 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 ...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now