mirror of
https://github.com/qbcore-fivem/qb-core.git
synced 2026-08-29 01:01:24 +00:00
⚠️ Major Update ⚠️
- Major cleanup of all files including reformatting & notations - Added an optional export to add to scripts as an alternative to import.lua - Added player state to OnPlayerLoaded so no more need for isLoggedIn inside scripts - Updated all events to the new RegisterNetEvent and got rid of unneeded handlers - Added the ability for ACE permissions with commands - Added two new config options for player update interval and status update - Changed players table to use citizenid column as primary key <-- very important - Overall sloppy code cleanup, removal of unused code, got rid of nil checks
This commit is contained in:
+20
-45
@@ -1,48 +1,23 @@
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Citizen.Wait(7)
|
||||
if NetworkIsSessionStarted() then
|
||||
Citizen.Wait(10)
|
||||
TriggerServerEvent('QBCore:PlayerJoined')
|
||||
return
|
||||
end
|
||||
end
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(0)
|
||||
if LocalPlayer.state['isLoggedIn'] then
|
||||
Wait((1000 * 60) * QBCore.Config.UpdateInterval)
|
||||
TriggerServerEvent('QBCore:UpdatePlayer')
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Citizen.Wait(7)
|
||||
if isLoggedIn then
|
||||
Citizen.Wait((1000 * 60) * 5)
|
||||
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
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(QBCore.Config.StatusInterval)
|
||||
if LocalPlayer.state['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)
|
||||
Reference in New Issue
Block a user