Files
qb-core-qbcore-fivem/client/loops.lua
T
Duo 7f03857fe6 Add check for 'isinlaststand'
Prevents player taking damage from hunger after they are already downed.
2023-01-13 10:52:38 -08:00

25 lines
880 B
Lua

CreateThread(function()
while true do
local sleep = 0
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 (QBCore.PlayerData.metadata['hunger'] <= 0 or QBCore.PlayerData.metadata['thirst'] <= 0) and not (QBCore.PlayerData.metadata['isdead'] or QBCore.PlayerData.metadata["inlaststand"]) then
local ped = PlayerPedId()
local currentHealth = GetEntityHealth(ped)
local decreaseThreshold = math.random(5, 10)
SetEntityHealth(ped, currentHealth - decreaseThreshold)
end
end
Wait(QBCore.Config.StatusInterval)
end
end)