Jump to content

Script freeze server


WASSIm.

Recommended Posts

hi guys, i have problem with script if start any resource server will take max of ram and got freezed

addEventHandler("onResourceStart", root, 
function (resource)    
    if (enableCompile) and (compileres[resource]) then 
        --setResourceInfo(resource, "laststart", date) 
        local resourceName = getResourceName(resource) 
        for indox, script in ipairs (getResourceScripts(resource)) do 
            local localFile = ":"..resourceName.."/"..script.."" 
            local theScript = fileExists(localFile) and fileOpen(localFile, true) 
            if (theScript) then 
                local code = fileRead(theScript, fileGetSize(theScript)) 
                fileClose(theScript) 
                if not (string.byte(code) == 28) then 
                    disableJoinonSetup = true 
                    fetchRemote("https://luac.multitheftauto.com/?compile=1&debug=1&obfuscate=1",  
                    function(responseData, error) 
                        if (error == 0) and (responseData) then 
                            if (string.find(responseData, "ERROR")) then 
                                --outputDebugString(localFile..": "..responseData.."", 1) 
                            else 
                                fileDelete(localFile) 
                                local theScriptC = fileCreate(localFile) 
                                fileWrite(theScriptC, responseData) 
                                fileClose(theScriptC) 
                                outputDebugString(localFile..": Successfully compiled", 3) 
                            end 
                        else 
                            outputDebugString(localFile..": Failed to compiled", 1) 
                        end 
                    end, code, true) 
                    if (indox == #getResourceScripts(resource)) then 
                        disableJoinonSetup = false 
                        restartResource(resource) 
                    end 
                else 
                    --outputDebugString(localFile..": Already compiled", 3) 
                end 
            end 
        end 
    end 
end) 

Link to comment

Can you try this and tell me if you saw "ss" and "ss2" in debug?

  
addEventHandler("onResourceStart", root, 
function (resource)   
    if (enableCompile) and (compileres[resource]) then 
        --setResourceInfo(resource, "laststart", date) 
        local resourceName = getResourceName(resource) 
        for indox, script in ipairs (getResourceScripts(resource)) do 
            local localFile = ":"..resourceName.."/"..script.."" 
            local theScript = fileExists(localFile) and fileOpen(localFile, true) 
            outPutDebugString("ss") 
            if (theScript) then 
                outPutDebugString("ss2") 
                local code = fileRead(theScript, fileGetSize(theScript)) 
                fileClose(theScript) 
                if not (string.byte(code) == 28) then 
                    disableJoinonSetup = true 
                    fetchRemote("https://luac.multitheftauto.com/?compile=1&debug=1&obfuscate=1", 
                    function(responseData, error) 
                        if (error == 0) and (responseData) then 
                            if (string.find(responseData, "ERROR")) then 
                                --outputDebugString(localFile..": "..responseData.."", 1) 
                            else 
                                fileDelete(localFile) 
                                local theScriptC = fileCreate(localFile) 
                                fileWrite(theScriptC, responseData) 
                                fileClose(theScriptC) 
                                outputDebugString(localFile..": Successfully compiled", 3) 
                            end 
                        else 
                            outputDebugString(localFile..": Failed to compiled", 1) 
                        end 
                    end, code, true) 
                    if (indox == #getResourceScripts(resource)) then 
                        disableJoinonSetup = false 
                        restartResource(resource) 
                    end 
                else 
                    --outputDebugString(localFile..": Already compiled", 3) 
                end 
            end 
        end 
    end 
end) 
  

Link to comment
  • MTA Team

outPutDebugString("ss") 

You misspelled it, it should be

outputDebugString 

Also, the reason i'm sure is that you have a lot of resources and of course it freezes your server as it doesn't have enough ram to process all the requests.

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