Refresh file.lua in cache ressource without restart resource

hello, is it possible to have this kind of modification without having to restart the script so just restart a lua file?

thank you in advance.

Before the modification
before

After the modification
after

function ReloadScript()
    local resource = GetCurrentResourceName()
    local filePath = "client/modules/escape.lua"
    local fileContent = LoadResourceFile(resource, filePath)
    
    print(fileContent)

    if fileContent then
        assert(load(fileContent))()
        print("File reload")
    else
        print("No file reload")
    end
end

Hello, this is a friendly reminder because this is your first time creating a topic (or it has been a while since your last topic) in this category.

Please note that most of the support is provided by the Cfx.re community on a voluntary basis. We ask you to be patient; there is no guarantee we have a solution to your problem(s). To avoid unnecessary/duplicate topics, please browse the forums before creating a topic.

To improve your chances of your issue(s) being solved, please provide as much information as possible about the issue(s) you are having. Also —whenever possible— please use the template given to you when creating a topic.

Thanks for keeping these forums tidy!
:mascot:

1 Like

The client won’t receive the updated files until you restart the resource. You are better off just using replicated convars for configuration, or some own logic using events.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.