Skip to content

Commit a08a950

Browse files
committed
bring in loops, will change
1 parent 493d5b7 commit a08a950

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

client/loops.lua

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
-- CreateThread(function()
2+
-- while not NetworkIsSessionStarted() do Wait(500) end
3+
-- print('player has loaded at this point')
4+
-- end)
5+
6+
CreateThread(function()
7+
while true do
8+
local sleep = 1000
9+
if LocalPlayer.state.isLoggedIn then
10+
sleep = (1000 * 60) * QBCore.Config.UpdateInterval
11+
TriggerServerEvent('QBCore:UpdatePlayer')
12+
end
13+
Wait(sleep)
14+
end
15+
end)
16+
17+
CreateThread(function()
18+
while true do
19+
if LocalPlayer.state.isLoggedIn then
20+
if (LocalPlayer.state['metadata:hunger'] <= 0 or LocalPlayer.state['metadata:thirst'] <= 0)
21+
and not (LocalPlayer.state['metadata:isdead'] or LocalPlayer.state['metadata:inlaststand']) then
22+
local ped = PlayerPedId()
23+
local currentHealth = GetEntityHealth(ped)
24+
local decreaseThreshold = math.random(5, 10)
25+
if currentHealth - decreaseThreshold > 0 then
26+
SetEntityHealth(ped, currentHealth - decreaseThreshold)
27+
else
28+
SetEntityHealth(ped, 0)
29+
end
30+
end
31+
end
32+
Wait(QBCore.Config.StatusInterval)
33+
end
34+
end)

0 commit comments

Comments
 (0)