Moderators Popular Post IIYAMA Posted June 4, 2016 Moderators Popular Post Share Posted June 4, 2016 (edited) Automatic compile your whole resource. Do what you want with it, but keep the formal credits. Don't forget that compiling isn't just for protection, it was also meant for optimization! Version for universal resource compiler: (NEW) resourceCompiler/meta.xml <meta> <info author="IIYAMA" type="script" name="Resource compiler" version="1.3.0" /> <script src="scripts/compiler_s.lua" /> <export function="compileResource" type="server"/> <aclrequest> <right name="function.fetchRemote" access="true" /> <right name="general.ModifyOtherObjects" access="true" /> </aclrequest> </meta> resourceCompiler/scripts/compiler_s.lua ------------------ -- by IIYAMA -- function compileResource (player, resourceName) if hasObjectPermissionTo ( player, "function.shutdown", false ) and getResourceFromName ( resourceName ) then if not hasObjectPermissionTo ( getThisResource (), "function.fetchRemote", false ) then outputChatBox(" ", player) outputChatBox("Require fetchRemote to compiling this resource!", player, 255, 0, 0) outputChatBox(" ", player) else local meta = xmlLoadFile(":" .. resourceName .. "/meta.xml") if meta then local folderName = "compiled/".. resourceName --.. "_compiled" local newMeta = xmlCopyFile(meta, folderName .. "/meta.xml") if newMeta then local metaNotes = xmlNodeGetChildren(meta) for i=1, #metaNotes do local metaNote = metaNotes[i] local scriptName = xmlNodeGetAttribute(metaNote, "src") if not scriptName or not string.match(scriptName, "compiler.lua") then if xmlNodeGetName(metaNote) == "script" then if scriptName and scriptName ~= "" then local FROM = ":" .. resourceName .. "/" .. scriptName local TO = folderName .. "/" .. scriptName .. "c" local scriptFile = fileOpen(FROM) fetchRemote( "https://luac.multitheftauto.com/?compile=1&debug=0&obfuscate=2", function(data) local newscriptFile = fileCreate ( TO ) if newscriptFile then fileWrite(newscriptFile, data) fileFlush(newscriptFile) fileClose(newscriptFile) end end, fileRead(scriptFile, fileGetSize ( scriptFile )) , true )--fileLoad(FROM) --https://luac.multitheftauto.com/api/ fileClose(scriptFile) end else local fileName = xmlNodeGetAttribute(metaNote, "src") if fileName then fileCopy (":" .. resourceName .. "/" .. fileName, folderName .. "/" .. fileName, true ) end end end end local newMetaNotes = xmlNodeGetChildren(newMeta) for i=1, #newMetaNotes do local newMetaNote = newMetaNotes[i] if xmlNodeGetName(newMetaNote) == "script" then local scriptName = xmlNodeGetAttribute(newMetaNote, "src") if not string.match(scriptName, "compiler.lua") then if scriptName and scriptName ~= "" then xmlNodeSetAttribute ( newMetaNote, "src", scriptName .. "c" ) end else xmlDestroyNode(newMetaNote) end end end xmlSaveFile(newMeta) xmlUnloadFile(newMeta) end xmlUnloadFile(meta) outputChatBox("Compiling done!", player, 0, 200, 0) end end end return true end addCommandHandler("compile", function (player, commandName, resourceName ) compileResource (player, resourceName) end) Installation: Put everything inside the folder resourceCompiler. (see file path for file name and sub folders) Use the commando: /refresh Give the resource the required rights(login as admin before you use this commando):/aclrequest allow resourceCompiler all This commando will give the resource all the rights that are defined in the meta.xml. (those are required to make the resource work) Rights: Spoiler <right name="function.fetchRemote" access="true" /> This right for the function fetchRemote will make sure that you can send and receive your code. (to the mta compiler) <right name="general.ModifyOtherObjects" access="true" /> This right will allow the resource to read and edit the files of other resources. (In this case it is for reading and copy files) Usage: /compile [resourceName] There is an export function you can use. Now you are ready to go! Don't forget to leave a like! EXCLUDED (but can be included) Do you want to compile resources it in your admin panel as well? That would be nice right? (This source code is only on request because I do not want to be responsible for releasing a version of admin panel. My credits isn't on it as well) Like this post + send me a PM to get a look at the adminpanel adjustments! A PM with just: 'yes I want this!' is enough! Installation: Spoiler Remove the default admin resource. (pls make a backup) Add the new admin resource you will receive from me. Command: /refreshall Give the admin group the acl right: command.compileElse you wouldn't be able to press the 'compile' button. <right name="command.compile" access="true"></right> Usage: Spoiler Make sure that the resources admin and resourceCompiler are running. Press your damn super super easy left mouse button on top of the 'compile' button in adminpanel. It will give feedback inside the adminpanel if the export is successfully. Take a look in > resourceCompiler\compiled < This is where all your compiled resources will show up.You can use this folder as an administration method for the resources you will upload to your server. Version for compiling inside the same resource: (OLD, but still useful) Spoiler Serverside ------------------ -- by IIYAMA -- addCommandHandler("compileScripts", function (player) if ( hasObjectPermissionTo ( player, "function.shutdown", false ) ) then local meta = xmlLoadFile("meta.xml") if meta then local folderName = getResourceName (getThisResource ()) .. "_compiled" local newMeta = xmlCopyFile(meta,folderName .. "/meta.xml") if newMeta then local metaNotes = xmlNodeGetChildren(meta) for i=1, #metaNotes do local metaNote = metaNotes[i] if xmlNodeGetName(metaNote) == "script" then local scriptName = xmlNodeGetAttribute(metaNote, "src") if scriptName and scriptName ~= "" then local FROM = scriptName local TO = folderName .. "/" .. scriptName .. "c" local scriptFile = fileOpen(FROM) fetchRemote( "https://luac.multitheftauto.com/?compile=1&debug=0&obfuscate=2", function(data) local newscriptFile = fileCreate ( TO ) if newscriptFile then fileWrite(newscriptFile, data) fileFlush(newscriptFile) fileClose(newscriptFile) end end, fileRead(scriptFile, fileGetSize ( scriptFile )) , true )--fileLoad(FROM) --https://luac.multitheftauto.com/api/ fileClose(scriptFile) end else local fileName = xmlNodeGetAttribute(metaNote, "src") if fileName then fileCopy ( fileName, folderName .. "/" .. fileName, true ) end end end local newMetaNotes = xmlNodeGetChildren(newMeta) for i=1, #newMetaNotes do local newMetaNote = newMetaNotes[i] if xmlNodeGetName(newMetaNote) == "script" then local scriptName = xmlNodeGetAttribute(newMetaNote, "src") if scriptName and scriptName ~= "" then xmlNodeSetAttribute ( newMetaNote, "src", scriptName .. "c" ) end end end xmlSaveFile(newMeta) xmlUnloadFile(newMeta) end xmlUnloadFile(meta) outputChatBox("Compiling done!") end end end) Add those line in your mta script. (serverside) Make sure your resource has admin rights to use the function fetchRemote. write: /compileScripts Check out the folder of your resource. A new folder will show up, with the name: _compiled Edited June 9, 2017 by IIYAMA 7 1 Link to comment
anonimbro Posted May 24, 2017 Share Posted May 24, 2017 woow thanks man I needed such a thing 1 Link to comment
Moderators IIYAMA Posted June 9, 2017 Author Moderators Share Posted June 9, 2017 (edited) (NOT little) * source code = update! Edited June 9, 2017 by IIYAMA Link to comment
iMr.WiFi..! Posted August 22, 2017 Share Posted August 22, 2017 there already compile system .-.https://community.multitheftauto.com/index.php?p=resources&s=details&id=9219 check mods if you dont want to tradition, good luck . Link to comment
Master_MTA Posted August 22, 2017 Share Posted August 22, 2017 On ٩/٦/٢٠١٧ at 19:35, IIYAMA said: (NOT little) * source code = update! am really like it it's so easy to understand and edit 1 Link to comment
Moderators IIYAMA Posted August 22, 2017 Author Moderators Share Posted August 22, 2017 9 hours ago, iMr.WiFi..! said: there already compile system .-.https://community.multitheftauto.com/index.php?p=resources&s=details&id=9219 check mods if you dont want to tradition, good luck . True, yet this one is different. Fully automatic finding all the scripts. Copying other files to the new folder so you have 2 versions. And most of all, this one you have to install yourself. Which might be an achievement for some people. 1 Link to comment
VenomOG Posted August 28, 2017 Share Posted August 28, 2017 How do i Decompile it once Compiled? Link to comment
kikos500 Posted August 28, 2017 Share Posted August 28, 2017 You can't decompile a script 1 Link to comment
koragg Posted September 8, 2017 Share Posted September 8, 2017 On 28.08.2017 г. at 23:09, kikos500 said: You can't decompile a script Which is why i keep mine decompiled in folders. If security means so much pain in the ass if i wanna edit it then no thanks But awesome resource for those who need it 1 Link to comment
Moderators IIYAMA Posted September 8, 2017 Author Moderators Share Posted September 8, 2017 Hmm, it is not that much of a pain if it only takes one button / command to make a compiled copy which ends up in 1 folder. But indeed, it will takes some management work. Link to comment
FernandoMTA Posted January 6, 2021 Share Posted January 6, 2021 Good job! Will be editing and using this! 1 Link to comment
Recommended Posts