DBY Posted October 17, 2015 Posted October 17, 2015 I want to compile a file using API mta. But there are two functions that do not exist in MTA (fileSave and fileLoad) Any ideas? https://luac.multitheftauto.com/api/ local FROM="example.lua" local TO="compiled.lua" fetchRemote( "https://luac.multitheftauto.com/?compile=1&debug=0&obfuscate=0", function(data) fileSave(TO,data) end, fileLoad(FROM), true ) YT Channel
N1kS Posted October 17, 2015 Posted October 17, 2015 You can write it... function fileSave( File, Data ) if( fileExists( File ) ) then fileDelete( File ); end local File = fileCreate( File ); fileWrite( File, Data ); fileClose( File ); end function fileLoad( File ) return fileRead( File, fileGetSize( File ) ); end skype: shadow_niks
DBY Posted October 17, 2015 Author Posted October 17, 2015 You can write it... function fileSave( File, Data ) if( fileExists( File ) ) then fileDelete( File ); end local File = fileCreate( File ); fileWrite( File, Data ); fileClose( File ); end function fileLoad( File ) return fileRead( File, fileGetSize( File ) ); end That I had already tried, but still not working. (Now do not get errors in the debugscript) YT Channel
Kenix Posted October 17, 2015 Posted October 17, 2015 Try function fileSave( sFile, sData ) if fileExists( sFile ) then fileDelete( sFile ); end local pFile = fileCreate( sFile ); fileWrite( pFile, sData ); fileClose( pFile ); end function fileLoad( sFile ) local pFile = fileOpen( sFile, true ); local sData = fileRead( pFile, fileGetSize( pFile ) ); fileClose( pFile ); return sData; end http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
DBY Posted October 17, 2015 Author Posted October 17, 2015 Try function fileSave( sFile, sData ) if fileExists( sFile ) then fileDelete( sFile ); end local pFile = fileCreate( sFile ); fileWrite( pFile, sData ); fileClose( pFile ); end function fileLoad( sFile ) local pFile = fileOpen( sFile, true ); local sData = fileRead( pFile, fileGetSize( pFile ) ); fileClose( pFile ); return sData; end Thank you very much for commenting, but these functions do the same thing that I've done. PS: Still not working. YT Channel
Kenix Posted October 17, 2015 Posted October 17, 2015 Please show me full script. http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
DBY Posted October 17, 2015 Author Posted October 17, 2015 function fileSave(filePath, fileContent) if fileExists(filePath) then fileDelete(filePath) end local file = fileCreate(filePath) fileWrite(file, fileContent) fileClose(file) end function fileLoad(filePath) if fileExists(filePath) then local file = fileOpen(filePath) local fileContent = fileRead(file, fileGetSize(file)) fileClose(file) return fileContent end end function fileCompile(FROM, TO) if FROM and TO then fetchRemote("https://luac.multitheftauto.com/?compile=1&debug=0&obfuscate=0", function(data) fileSave(TO, data) end, fileLoad(FROM), true) end end The problem now is that it creates the file but the page returns "ERROR" YT Channel
N1kS Posted October 17, 2015 Posted October 17, 2015 Works for me: function fileSave( sFile, sData ) if fileExists( sFile ) then fileDelete( sFile ); end local pFile = fileCreate( sFile ); fileWrite( pFile, sData ); fileClose( pFile ); end function fileLoad( sFile ) local pFile = fileOpen( sFile, true ); local sData = fileRead( pFile, fileGetSize( pFile ) ); fileClose( pFile ); return sData; end local FROM="example.lua" local TO="compiled.luac" fetchRemote( "https://luac.multitheftauto.com/?compile=1&debug=0&obfuscate=0", function(data) print( tostring( data ) ) fileSave( TO, data ) end, fileLoad( FROM ), true ); skype: shadow_niks
Noki Posted October 17, 2015 Posted October 17, 2015 The problem now is that it creates the file but the page returns "ERROR" The page on a web browser displays "ERROR" when the uploaded file has a syntax error.
UserToDelete Posted October 17, 2015 Posted October 17, 2015 The problem now is that it creates the file but the page returns "ERROR" The page on a web browser displays "ERROR" when the uploaded file has a syntax error. Or fileLoad or codification doesnt work
Noki Posted October 17, 2015 Posted October 17, 2015 No, the file functions he is using return bools, file handlers or an integer representing a number of bytes either read or written. The only way "ERROR" could be returned is through fetchRemote.
DBY Posted October 18, 2015 Author Posted October 18, 2015 The script creates the file, but inside it there is only "ERROR" YT Channel
UserToDelete Posted October 18, 2015 Posted October 18, 2015 function fileLoad(path) local File = fileOpen(path, true) if File then local data = fileRead(File, fileGetSize(File)) fileClose(File) return data end end function fileSave(path, data) local File = fileCreate(path) if File then fileWrite(File, data) fileClose(File) end end
DBY Posted October 18, 2015 Author Posted October 18, 2015 function fileLoad(path) local File = fileOpen(path, true) if File then local data = fileRead(File, fileGetSize(File)) fileClose(File) return data end end function fileSave(path, data) local File = fileCreate(path) if File then fileWrite(File, data) fileClose(File) end end Your code does the same job as my code. Still creates a file containing "ERROR". YT Channel
Noki Posted October 18, 2015 Posted October 18, 2015 If it throws an error when you try to compile the script on the website, then you have a syntax error in your script. It works fine for me and it throws "ERROR" when I try to compile a file with a syntax error.
DBY Posted October 18, 2015 Author Posted October 18, 2015 If it throws an error when you try to compile the script on the website, then you have a syntax error in your script. It works fine for me and it throws "ERROR" when I try to compile a file with a syntax error. I put "print()" into file i want compile. But still return "error" YT Channel
MisterQuestions Posted October 18, 2015 Posted October 18, 2015 https://wiki.multitheftauto.com/wiki/GetResourceScripts "El conocimiento jamás debe detenerse, por que es lo único que nos salvará cuando no nos quede más". Att: -|TG|-Mister[Q]<.
The Don Posted October 18, 2015 Posted October 18, 2015 https://community.multitheftauto.com/in ... ls&id=9219 آن يكون فكر المرء مختلآ , خيرآ من آن يكون فكره محتلآ ! my nick name in the game : =x=|DoN|=x= or 7eJAzZy- ( ͡° ͜ʖ ͡°) http://community.multitheftauto.com/ind ... &id=337164 my profile
DBY Posted October 18, 2015 Author Posted October 18, 2015 Apparently, the problem is not the script, it's my localhost. FetchRemote not work, I tried some compilers and none worked for me. Your comments are appreciated. YT Channel
MisterQuestions Posted October 19, 2015 Posted October 19, 2015 Apparently, the problem is not the script, it's my localhost. FetchRemote not work, I tried some compilers and none worked for me.Your comments are appreciated. Lel, the test funct from getResourceScripts works perfectly for compiling Just modify the funct. Add xmlUnloadFile for meta xmlFile (or will keep opening files and stay loaded at memory). "El conocimiento jamás debe detenerse, por que es lo único que nos salvará cuando no nos quede más". Att: -|TG|-Mister[Q]<.
Saml1er Posted November 19, 2015 Posted November 19, 2015 Because you need to do port forwarding. Execute "openports" in your server console and it will you whether your ports are open or no. If no then do port forwarding.
Addlibs Posted November 19, 2015 Posted November 19, 2015 (edited) Because you need to do port forwarding. Execute "openports" in your server console and it will you whether your ports are open or no. If no then do port forwarding. Port forwarding (in regards to /openports) is for incoming connections, not outgoing. The API server already has the necessary ports open, and therefore connection should work (unless there's firewall the outgoing server) Edited November 19, 2015 by Guest Previously known as MrTasty.
Saml1er Posted November 19, 2015 Posted November 19, 2015 Because you need to do port forwarding. Execute "openports" in your server console and it will you whether your ports are open or no. If no then do port forwarding. Port forwarding is for incoming connections, not outgoing. The API server already has the necessary ports open, and therefore connection should work (unless there's firewall the outgoing server) I wonder why callRemote was not working for me when my ports were not open? Hmmm I think it was an year ago.
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