Jump to content

Compile lua file api


DBY

Recommended Posts

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 

Link to comment
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)

Link to comment

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 

Link to comment
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.

Link to comment
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"

Link to comment

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 ); 

Link to comment

tumblr_mkiylvrDGJ1qbkjb0o1_500.gif

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 

Link to comment
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".

Link to comment
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"

Link to comment
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).

Link to comment
  • 1 month later...
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 by Guest
Link to comment
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.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...