CfxLua CLI is a standalone verification and static analysis tool for FiveM Lua scripts.
Standard Lua checkers (like luac) fail when encountering FiveM's specific Lua flavour—which includes custom power patches (like each iterators and safe navigation) and first-class vector/matrix types. This toolchain solves that by providing a server-independent environment powered by the same specialized LuaGLM 5.4 VM used by CitizenFX.
- Native FiveM Support: Full support for CitizenFX Lua 5.4 features, including
eachiterators,defer, safe navigation (?.), and callable vectors/quaternions. - MagicMock System: Automatically handles missing globals (e.g.,
lib,ox_inventory, or client-only natives) by returning intelligent, indexable/callable stubs instead of crashing. - Lazy Resource Discovery: Dynamically scans your
resources/folder to discover and mock exports from other resources, enabling cross-resource static analysis. - Execution Safety: Integrated timeout protection (default 5s) prevents verification hangs on scripts containing infinite loops (like
while true do Wait(0) end). - Powered by LuaGLM: High-performance mathematics support with first-class vector, matrix, and quaternion types.
Download the latest package for your platform from the Releases page.
- Extract the
.tar.gzarchive. - Run the installer:
sudo ./install.sh
- Extract the
.ziparchive. - Run
install.batas Administrator (to ensure PATH is updated). - Restart your terminal.
Requirements: build-essential, cmake, and mingw-w64 (for Windows cross-compilation).
git clone https://github.com/VIRUXE/cfxlua-cli.git
cd cfxlua-cli
make -j$(nproc)
sudo ./install.shTo verify a script, simply pass the file path to the cfxlua command:
cfxlua path/to/your/resource/server.luaCFXLUA_TIMEOUT: Execution timeout in milliseconds (default:5000).CFXLUA_VM: Path to a custom Lua VM binary.CFXLUA_RUNTIME: Path to a custom runtime mock directory.
The tool attempts to resolve unknown exports by searching for an fxmanifest.lua in sibling directories. If an export like exports.qbx_core:Notify() is encountered, it will find the qbx_core resource and automatically stub the requested function.
If your script relies on external libraries (like ox_lib) that aren't present in the standalone environment, the MagicMock system ensures that calls to lib.* or undefined natives return nil or dummy objects gracefully, allowing the syntax check to continue.
This toolchain is built upon LuaGLM, a Lua 5.4.4 runtime providing complete bindings to the GLM C++ mathematics library.
Vectors are first-class, immutable types. You can use standard GLSL swizzling and arithmetic:
local v = vec(1.0, 2.0, 3.0)
print(v.xyz) -- vec3(1.0, 2.0, 3.0)
print(#v) -- 3.74165 (Magnitude)- Compound Operators:
+=,-=,*=,/=, etc. - Safe Navigation:
t?.x?.yreturnsniliftorxare missing. - In Unpacking:
local a, b in t(Unpacks keys from tablet). - Each Iteration:
for k, v in each(t) do ... end.
Contributions to improve mocks, add support for more FiveM-specific patterns, or enhance the resource discovery logic are welcome!
- Fork the repository.
- Create your feature branch (
git checkout -b feat/amazing-mock). - Commit your changes.
- Push to the branch and open a Pull Request.
- VIRUXE: Advanced Mocks and CLI Toolchain.
- Cfx.re: Original LuaGLM 5.4 runtime and FiveM integration patches.
- Polaris Naz: Performance patches and execution safety logic.
- Lua Team: The base Lua language.
This project is licensed under the MIT License. See lua.h for the original Lua copyright notice.