-
Posts
1,248 -
Joined
-
Last visited
Everything posted by WhoAmI
-
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 )
-
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?
-
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.
-
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.
-
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
-
Past your code with loading items to gridlist.
-
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 )
-
You can try that. That may be causing a problem. Whole file should be opened servisde I guess. Just get 'xmlNodeGetChrildren' serverside, trigger it to client and loop it there.
-
I have no idea when the error can be.
-
So there is an error with loadng the file? You are loading it clientside?
-
Give me code you have.
-
Add 'break' line after changing value so it won't loop for other songs. Like that function updatePlayed (songName) local file = xmlLoadFile ( "songs.xml" ) for _, v in ipairs ( xmlNodeGetChildren ( file ) ) do if ( xmlNodeGetAttribute ( v, "name" ) == songName ) then xmlNodeSetAttribute ( v, "played", tonumber ( xmlNodeGetAttribute ( v, "played" ) ) + 1 ) break; end end xmlSaveFile ( file ) xmlUnloadFile ( file ) end
-
Turn off skins and check if crash will be up again.
-
function updatePlayed (songName) local file = xmlLoadFile ( "songs.xml" ) for _, v in ipairs ( xmlNodeGetChildren ( file ) ) do if ( xmlNodeGetAttribute ( v, "name" ) == songName ) then xmlNodeSetAttribute ( v, "played", tonumber ( xmlNodeGetAttribute ( v, "played" ) ) + 1 ) end end xmlSaveFile ( file ) xmlUnloadFile ( file ) end
-
Same errors? Show me your code you have in file again.
-
In my opinion, those script which cause it has some bad mods.
-
Copy my code again. I changed it. You can't have this xmlSave/xmlUnload functions inside loop.
-
function updatePlayed (songName) local file = xmlLoadFile ( "songs.xml" ) if ( not file ) then outputChatBox ( "ERROR" ); return; end for _, v in ipairs ( xmlNodeGetChildren ( file ) ) do if ( xmlNodeGetAttribute ( v, "name" ) == songName ) then xmlNodeSetAttribute ( v, "played", xmlNodeGetAttribute ( v, "played" ) + 1 ) end end xmlSaveFile ( file ) xmlUnloadFile ( file ) end Check if in chatbox won't be any error.
-
If it happens to everyone, then it's probably resource(s) fault.
-
Good to see it.
-
Get name. Loop for all children's and check if children's name == name. Like that songNameToEdit = "some song"; local file = xmlLoadFile ( "songs.xml" ) for _, v in ipairs ( xmlNodeGetChildren ( file ) ) do if ( xmlNodeGetAttribute ( v, "name" ) == songNameToEdit ) then xmlNodeSetAttribute ( v, "played", xmlNodeGetAttribute ( v, "played" ) + 1 ) end xmlSaveFile ( file ) xmlUnloadFile ( file )