Jump to content

fetchRemote


WASSIm.

Recommended Posts

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

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

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...