From a08a950e73588ae40afff981875b69c83f1238e6 Mon Sep 17 00:00:00 2001 From: Kakarot <57848836+GhzGarage@users.noreply.github.com> Date: Tue, 11 Mar 2025 23:35:12 -0500 Subject: [PATCH] bring in loops, will change --- client/loops.lua | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 client/loops.lua diff --git a/client/loops.lua b/client/loops.lua new file mode 100644 index 0000000..5a894f1 --- /dev/null +++ b/client/loops.lua @@ -0,0 +1,34 @@ +-- CreateThread(function() +-- while not NetworkIsSessionStarted() do Wait(500) end +-- print('player has loaded at this point') +-- end) + +CreateThread(function() + while true do + local sleep = 1000 + if LocalPlayer.state.isLoggedIn then + sleep = (1000 * 60) * QBCore.Config.UpdateInterval + TriggerServerEvent('QBCore:UpdatePlayer') + end + Wait(sleep) + end +end) + +CreateThread(function() + while true do + if LocalPlayer.state.isLoggedIn then + if (LocalPlayer.state['metadata:hunger'] <= 0 or LocalPlayer.state['metadata:thirst'] <= 0) + and not (LocalPlayer.state['metadata:isdead'] or LocalPlayer.state['metadata:inlaststand']) then + local ped = PlayerPedId() + local currentHealth = GetEntityHealth(ped) + local decreaseThreshold = math.random(5, 10) + if currentHealth - decreaseThreshold > 0 then + SetEntityHealth(ped, currentHealth - decreaseThreshold) + else + SetEntityHealth(ped, 0) + end + end + end + Wait(QBCore.Config.StatusInterval) + end +end)