flowz Posted September 21, 2014 Share Posted September 21, 2014 I have over 30+ resources that need re-compiling, how can I do it all at once? D; It took me like 5 mins to do 6 resources. It's really hard and takes up too much time.. Please help. Link to comment
King12 Posted September 21, 2014 Share Posted September 21, 2014 -- Server side Resources = { "script3", -- resource name "script2", -- resource name "script1", -- resource name } Working = false Current = 1 loading = false function forceLoad() if Resources[Current] then outputDebugString("[Compiler] "..Resources[Current], 0,55,167,220) local xmlPatch = ":"..Resources[Current].."/meta.xml" local xmlFile = xmlLoadFile(xmlPatch) if xmlFile then --Map Scripts local index = 0 local scriptNode = xmlFindChild(xmlFile,'script',index) if scriptNode then repeat local scriptPath = xmlNodeGetAttribute(scriptNode,'src') or false local scriptType = xmlNodeGetAttribute(scriptNode,'type') or "server" if scriptPath and scriptType:lower() == "client" then if string.find(scriptPath:lower(), "luac") then outputDebugString("COMPILER SYSTEM: File "..scriptPath.." is already compiled",3,220,20,20) else local FROM=":"..Resources[Current].."/"..scriptPath local TO= ":"..Resources[Current].."/"..scriptPath.."c" fetchRemote( "https://luac.multitheftauto.com/?compile=1&debug=0&blockdecompile=0&encrypt=0", function(data) fileSave(TO,data) end, fileLoad(FROM), true ) xmlNodeSetAttribute(scriptNode,'src',scriptPath..'c') outputDebugString("COMPILER SYSTEM: ".. TO.." Compiled and Saved successfully",3,0,255,0) end end index = index + 1 scriptNode = xmlFindChild(xmlFile,'script',index) until not scriptNode end xmlSaveFile(xmlFile) xmlUnloadFile(xmlFile) else outputDebugString("COMPILER SYSTEM: Cant read xmlFile: meta.xml",3,220,20,20) return false end --startResource(getResourceFromName(Resources[Current])) end Current = Current + 1 setTimer(forceLoad, 1000,1) end addCommandHandler ( "compileall", forceLoad ) function fileLoad(path) local File = fileOpen(path, true) if File then local data = fileRead(File, 500000000) fileClose(File) return data end end function fileSave(path, data) local File = fileCreate(path) if File then fileWrite(File, data) fileClose(File) end end Link to comment
flowz Posted September 21, 2014 Author Share Posted September 21, 2014 Do I have to place the resources in the directory of the script such as ' Folder 'scriptcompile' ' So I place all of the scripts that I need to compile in the same directory as script? Link to comment
flowz Posted September 21, 2014 Author Share Posted September 21, 2014 Thanks I got it , really useful +1 Link to comment
#RooTs Posted April 19, 2015 Share Posted April 19, 2015 seems that not working -- Server side Resources = { "script3", -- resource name "script2", -- resource name "script1", -- resource name } Working = false Current = 1 loading = false function forceLoad() if Resources[Current] then outputDebugString("[Compiler] "..Resources[Current], 0,55,167,220) local xmlPatch = ":"..Resources[Current].."/meta.xml" local xmlFile = xmlLoadFile(xmlPatch) if xmlFile then --Map Scripts local index = 0 local scriptNode = xmlFindChild(xmlFile,'script',index) if scriptNode then repeat local scriptPath = xmlNodeGetAttribute(scriptNode,'src') or false local scriptType = xmlNodeGetAttribute(scriptNode,'type') or "server" if scriptPath and scriptType:lower() == "client" then if string.find(scriptPath:lower(), "luac") then outputDebugString("COMPILER SYSTEM: File "..scriptPath.." is already compiled",3,220,20,20) else local FROM=":"..Resources[Current].."/"..scriptPath local TO= ":"..Resources[Current].."/"..scriptPath.."c" fetchRemote( "https://luac.multitheftauto.com/?compile=1&debug=0&blockdecompile=0&encrypt=0", function(data) fileSave(TO,data) end, fileLoad(FROM), true ) xmlNodeSetAttribute(scriptNode,'src',scriptPath..'c') outputDebugString("COMPILER SYSTEM: ".. TO.." Compiled and Saved successfully",3,0,255,0) end end index = index + 1 scriptNode = xmlFindChild(xmlFile,'script',index) until not scriptNode end xmlSaveFile(xmlFile) xmlUnloadFile(xmlFile) else outputDebugString("COMPILER SYSTEM: Cant read xmlFile: meta.xml",3,220,20,20) return false end --startResource(getResourceFromName(Resources[Current])) end Current = Current + 1 setTimer(forceLoad, 1000,1) end addCommandHandler ( "compileall", forceLoad ) function fileLoad(path) local File = fileOpen(path, true) if File then local data = fileRead(File, 500000000) fileClose(File) return data end end function fileSave(path, data) local File = fileCreate(path) if File then fileWrite(File, data) fileClose(File) end 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