Files
qb-core-qbcore-fivem/qb-core/client/loops.lua
T
2021-04-02 22:26:42 -05:00

48 lines
1015 B
Lua

Citizen.CreateThread(function()
while true do
Citizen.Wait(7)
if NetworkIsSessionStarted() then
Citizen.Wait(10)
TriggerServerEvent('QBCore:PlayerJoined')
return
end
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(7)
if isLoggedIn then
Citizen.Wait((1000 * 60) * 10)
TriggerEvent("QBCore:Player:UpdatePlayerData")
else
Citizen.Wait(5000)
end
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(7)
if isLoggedIn then
Citizen.Wait(30000)
TriggerEvent("QBCore:Player:UpdatePlayerPosition")
else
Citizen.Wait(5000)
end
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(math.random(3000, 5000))
if isLoggedIn then
if QBCore.Functions.GetPlayerData().metadata["hunger"] <= 0 or QBCore.Functions.GetPlayerData().metadata["thirst"] <= 0 then
local ped = PlayerPedId()
local currentHealth = GetEntityHealth(ped)
SetEntityHealth(ped, currentHealth - math.random(5, 10))
end
end
end
end)