diff --git a/client/loops.lua b/client/loops.lua index 970ae84..62b0f5d 100644 --- a/client/loops.lua +++ b/client/loops.lua @@ -1,23 +1,24 @@ CreateThread(function() while true do - Wait(0) + local sleep = 0 if LocalPlayer.state.isLoggedIn then - Wait((1000 * 60) * QBCore.Config.UpdateInterval) + sleep = (1000 * 60) * QBCore.Config.UpdateInterval TriggerServerEvent('QBCore:UpdatePlayer') end + Wait(sleep) end end) CreateThread(function() while true do - Wait(QBCore.Config.StatusInterval) - local PlayerData = QBCore.Functions.GetPlayerData() if LocalPlayer.state.isLoggedIn then - if (PlayerData.metadata['hunger'] <= 0 or PlayerData.metadata['thirst'] <= 0) and (not PlayerData.metadata['isdead']) then + if (QBCore.PlayerData.metadata['hunger'] <= 0 or QBCore.PlayerData.metadata['thirst'] <= 0) and not QBCore.PlayerData.metadata['isdead'] then local ped = PlayerPedId() local currentHealth = GetEntityHealth(ped) - SetEntityHealth(ped, currentHealth - math.random(5, 10)) + local decreaseTreshold = math.random(5, 10) + SetEntityHealth(ped, currentHealth - decreaseTreshold) end end + Wait(QBCore.Config.StatusInterval) end end)