Ahmed Ly Posted October 10, 2017 Share Posted October 10, 2017 (edited) function getfolderNameAndScripts (folder) tables = {} local xml = xmlLoadFile("meta.xml") local Nodes = xmlNodeGetChildren(xml) for i,node in ipairs(Nodes) do if xmlNodeGetName(node) == "script" then local script_Name = xmlNodeGetAttribute(node, "src") table.insert(tables,script_Name) output = "resources\\"..folder.."\\"..tables[#tables].. "" end end xmlUnloadFile(xml) return output end outputServerLog(""..getfolderNameAndScripts("acl").."") --[[ the code it's working good but its output last file .lua in meta.xml resources/acl/clinet.lua doesn't output in server log resources/acl/s.lua doesn't output in server log resources/acl/server.lua this file output in server log --]] Edited October 10, 2017 by Ahmed Ly Link to comment
Manticore Posted October 10, 2017 Share Posted October 10, 2017 Show me your Meta.xml, Maybe I'll try to help ya. Link to comment
Rockyz Posted October 10, 2017 Share Posted October 10, 2017 (edited) I didn't understand what are you trying to do but, that's an example : function getFolderNameAndScripts ( folder ) local script = ':' .. folder if ( fileExists ( script .. '/meta.xml' ) ) then scriptInfo = { }; local resourceMeta = xmlLoadFile ( script .. '/meta.xml' ) if ( resourceMeta ) then for k, info in pairs ( xmlNodeGetChildren ( resourceMeta ) ) do if ( xmlNodeGetName ( info ) == 'script' or xmlNodeGetName ( info ) == 'file' or xmlNodeGetName ( info ) == 'map' ) then table.insert ( scriptInfo, { script, xmlNodeGetAttribute ( info, 'src' ) or 'N/A', xmlNodeGetAttribute ( info, 'type' ) or 'N/A' } ) end end end end return scriptInfo or { }; end addEventHandler ( 'onResourceStart', root, function ( res ) outputChatBox ( 'The Resource ' .. getResourceName ( res ) .. ' has been started', root, 0, 255, 0, true ) outputChatBox ( 'Resource Scripts :', root, 255, 0, 0, true ) local items = getFolderNameAndScripts ( getResourceName ( res ) ) for i = 1, #items do local t = items [ i ] outputChatBox ( t [ 1 ]:gsub ( ':', 'resources/' ) .. '/' .. t [ 2 ] .. ', type = ' .. t [ 3 ], root, 0, 0, 255, true ) end end ) Edited October 10, 2017 by #,+( _xiRoc[K]; > Link to comment
Rockyz Posted October 10, 2017 Share Posted October 10, 2017 #edit : use xmlUnloadFile after inserting items on the table Link to comment
Ahmed Ly Posted October 10, 2017 Author Share Posted October 10, 2017 i fixed it function getFolderNameAndScripts (resourceName) if getResourceFromName(resourceName) then local scripts = {} local xml = xmlLoadFile(":" .. resourceName .. "/meta.xml") if xml then local nodes = xmlNodeGetChildren(xml) for i, node in ipairs(nodes) do if xmlNodeGetName(node) == "script" then local scriptName = xmlNodeGetAttribute(node, "src") scripts[#scripts + 1] = "deathmatch\\resources\\" ..resourceName.."\\"..scriptName end end xmlUnloadFile(xml) end return scripts end outputDebugString("No resource found to get the scripts from!", 2) return false end local items = getFolderNameAndScripts("acl") for i, v in ipairs(items) do iprint(""..v.."") end Link to comment
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