molfar_audit / Rules / LUA002
LUA002 Client loop runs every frame
possible Lua code
A while true loop on the client only ever waits Wait(0).
Why it matters
A loop that never sleeps runs on every frame for every player and lowers FPS. Loops that must run every frame (natives ending in ThisFrame, DisableControlAction) are not reported.
How to fix
Sleep longer while there is nothing to do, and switch to Wait(0) only when needed (for example near a marker).
Reported
CreateThread(function()
while true do
DrawMarker(1, coords.x, coords.y, coords.z, ...)
Wait(0)
end
end)Fixed
CreateThread(function()
while true do
local sleep = 1000
if #(GetEntityCoords(cache.ped) - coords) < 20.0 then
sleep = 0
DrawMarker(1, coords.x, coords.y, coords.z, ...)
end
Wait(sleep)
end
end)Not a problem in your case?
Add -- molfar-audit-ignore LUA002 on the reported line (or the line above it), or ignore it in config.json: "ignore": [{ "rule": "LUA002", "resource": "your_resource" }].