WASSIm. Posted November 29, 2013 Share Posted November 29, 2013 hi guys. who can tell me more info about fetchRemote i want make function compile script ! local FROM = "example.lua" local TO = "compiled.lua" fetchRemote( "https://luac.multitheftauto.com/?compile=1&debug=0&blockdecompile=0&encrypt=0", function(data) fileSave(TO,data) end, fileLoad(FROM), true ) Link to comment
WASSIm. Posted November 30, 2013 Author Share Posted November 30, 2013 only help plis ? Link to comment
Blaawee Posted November 30, 2013 Share Posted November 30, 2013 Maybe something like this : function compiledScirptFile( from, to ) if from and type( from ) == 'string' and to and type( to ) == 'string' then fetchRemote( 'https://luac.multitheftauto.com/?compile=1&debug=0&blockdecompile=0&encrypt=0', myCallBack, fileRead( from ), true, to ); end end function myCallBack( data, errno, path ) if errno == 0 then if not fileExists( ':'..sourceResource..'/'.. path ) then newFile = fileCreate( ':'..sourceResource..'/'.. path ) fileWrite( newFile, data ) fileClose( newFile ) end end end Link to comment
WASSIm. Posted November 30, 2013 Author Share Posted November 30, 2013 i remove fileRead and working but its write to new file ( ERROR Could not compile file ) Link to comment
Blaawee Posted November 30, 2013 Share Posted November 30, 2013 Actually i'm not good in these thing, But try to replace fileRead with fileOpen. might work. Link to comment
WASSIm. Posted November 30, 2013 Author Share Posted November 30, 2013 3: Bad argument @ 'fetchRemote' [Expected string at argument 3] Link to comment
Blaawee Posted November 30, 2013 Share Posted November 30, 2013 How did you use it ? compiledScirptFile("example.lua","compiled.lua") Link to comment
GTX Posted November 30, 2013 Share Posted November 30, 2013 https://luac.multitheftauto.com/api/ --Lua example: local FROM="example.lua" local TO="compiled.lua" fetchRemote( "https://luac.multitheftauto.com/?compile=1&debug=0&blockdecompile=0&encrypt=0", function(data) fileSave(TO,data) end, fileLoad(FROM), true ) Link to comment
TAPL Posted November 30, 2013 Share Posted November 30, 2013 @Blaawee, Where is sourceResource defined? --- fileSave + fileLoad look like a custom function to save and load the file. Link to comment
WASSIm. Posted November 30, 2013 Author Share Posted November 30, 2013 how make it working ? Link to comment
TAPL Posted November 30, 2013 Share Posted November 30, 2013 local FROM = "example.lua" local TO = "compiled.lua" 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 fetchRemote("https://luac.multitheftauto.com/?compile=1&debug=0&blockdecompile=1&encrypt=1", function(data) fileSave(TO, data) end, fileLoad(FROM), true) Link to comment
WASSIm. Posted November 30, 2013 Author Share Posted November 30, 2013 thank u its working but i change somethink EDIT debug: Bad 'file' pointer @ 'fileWrite'(1) addEventHandler("onResourceStart", getRootElement(), function (resource) local resourceName = getResourceName(resource) if ( string.find(resourceName, "ZA-") ) then local file = xmlLoadFile(":"..resourceName.."/meta.xml") for i, node in ipairs (xmlNodeGetChildren(file)) do if (xmlNodeGetName(node) == "script") then local src = xmlNodeGetAttribute(node, "src") local theScript = fileOpen(":"..resourceName.."/"..src, true) if (theScript) then local text = fileRead(theScript, 500000000) local theScriptC = fileOpen(":"..resourceName.."/"..src.."c", true) or fileCreate(":"..resourceName.."/"..src.."c") if (theScriptC) then if (fetchRemote("https://luac.multitheftauto.com/?compile=1&debug=0&blockdecompile=1&encrypt=1", function(textC) outputChatBox(textC) fileWrite(theScriptC, textC) end, text, true)) then outputDebugString(""..resourceName.."/"..src..": Successfully compiled") else outputDebugString(""..resourceName.."/"..src..": Failed to compiled", 3) end fileClose(theScriptC) fileClose(theScript) end end end end end end ) Link to comment
TAPL Posted November 30, 2013 Share Posted November 30, 2013 addEventHandler("onResourceStart", getRootElement(), function (resource) local resourceName = getResourceName(resource) if ( string.find(resourceName, "ZA-") ) then local file = xmlLoadFile(":"..resourceName.."/meta.xml") for i, node in ipairs (xmlNodeGetChildren(file)) do if (xmlNodeGetName(node) == "script") then local src = xmlNodeGetAttribute(node, "src") if (fetchRemote("https://luac.multitheftauto.com/?compile=1&debug=0&blockdecompile=1&encrypt=1", function(data) fileSave(":"..resourceName.."/"..src.."c", data) end, fileLoad(":"..resourceName.."/"..src), true)) then outputDebugString(""..resourceName.."/"..src..": Successfully compiled") else outputDebugString(""..resourceName.."/"..src..": Failed to compiled", 3) end end end end end ) 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