Jump to content

WhoAmI

Members
  • Posts

    1,248
  • Joined

  • Last visited

Everything posted by WhoAmI

  1. 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 )
  2. 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?
  3. 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.
  4. 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.
  5. 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
  6. Past your code with loading items to gridlist.
  7. 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 )
  8. 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.
  9. I have no idea when the error can be.
  10. So there is an error with loadng the file? You are loading it clientside?
  11. Give me code you have.
  12. 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
  13. WhoAmI

    crash

    Turn off skins and check if crash will be up again.
  14. 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
  15. Same errors? Show me your code you have in file again.
  16. WhoAmI

    crash

    In my opinion, those script which cause it has some bad mods.
  17. Copy my code again. I changed it. You can't have this xmlSave/xmlUnload functions inside loop.
  18. 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.
  19. WhoAmI

    crash

    If it happens to everyone, then it's probably resource(s) fault.
  20. 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 )
×
×
  • Create New...