This Node.js-based script is designed for FiveM servers to automatically monitor and restart resources whenever a .lua file within them changes. Itβs a developer-friendly utility that eliminates the need for manual restarts during development.
- Automatically scans all running resources and records the SHA1 hash of
.luafiles. - Checks every 60 seconds for:
- Changed
.luafiles. - Newly started resources.
- Stopped or removed resources.
- Changed
- Automatically restarts resources if any file change is detected.
- Ignores files in the
stream/directory (usually models or assets). - Toggleable via in-game or server console command.
- On script start, all active resources are scanned.
- For each
.luafile (excludingstream/), a hash is generated. - Every 60 seconds:
- New resources are added to the watch list.
- Stopped resources are removed from the list.
- File hashes are rechecked and compared.
- If a change is detected, the resource is restarted using
StopResourceandStartResource.
Before starting, make sure to install required dependencies using npm:
npm install-
Place the script in your server resource folder.
-
Add the following line to your
server.cfg:ensure autorestart
-
Start the server.
-
Use the following command to toggle auto-restart:
/autorestart
- Only
.luafiles are monitored. - Files inside the
stream/directory are excluded. - Only resources in the
startedstate are tracked. - This tool is intended for development purposes.
This tool is open source and created for the FiveM developer community.
Feel free to submit issues or pull requests to contribute.
For contact daglarefe.com