mirror of
https://github.com/qbcore-fivem/qb-core.git
synced 2026-08-29 02:01:33 +00:00
Refactor core structure and notification UI
Major refactor to centralize QBCore and replace the web UI stack: - Move QBConfig into a unified QBCore.Config and initialize QBCore.PlayerData; add shared/functions.lua. - Remove legacy client/main.lua and server/main.lua exports and update fxmanifest to include shared/functions and drop those main scripts. - Update client event handling: adapt player data events to QBCore:Client:OnPlayerUpdated and trigger job/gang update events; remove deprecated exploitable handlers. - Web UI rewrite: remove Vue/Quasar dependency and config module; implement a lightweight vanilla JS notification system (html/js/app.js) with updated html and css assets, plus drawtext tweaks. - CSS overhaul for notification styling and animations; HTML head/meta/font cleanup. - Server fixes: use QBCore.Shared.Locations in teleport command and strengthen numeric parsing/validation for coords. - Add .gitattributes for consistent text/eol handling and small code cleanups (thread/comment removal). These changes consolidate config/shared logic under QBCore, simplify the frontend dependencies, and fix a few parsing/event issues.
This commit is contained in:
+40
-50
@@ -55,12 +55,7 @@ end
|
||||
---@param citizenid string
|
||||
---@return table?
|
||||
function QBCore.Functions.GetPlayerByCitizenId(citizenid)
|
||||
for _, Player in pairs(QBCore.Players) do
|
||||
if Player.PlayerData.citizenid == citizenid then
|
||||
return Player
|
||||
end
|
||||
end
|
||||
return nil
|
||||
return QBCore.PlayersByCitizenId[citizenid]
|
||||
end
|
||||
|
||||
---Get offline player by citizen id
|
||||
@@ -304,16 +299,12 @@ end
|
||||
---@return table|boolean
|
||||
function QBCore.Functions.GetPlayersInBucket(bucket)
|
||||
local curr_bucket_pool = {}
|
||||
if QBCore.Player_Buckets and next(QBCore.Player_Buckets) then
|
||||
for _, v in pairs(QBCore.Player_Buckets) do
|
||||
if v.bucket == bucket then
|
||||
curr_bucket_pool[#curr_bucket_pool + 1] = v.id
|
||||
end
|
||||
for _, v in pairs(QBCore.Player_Buckets) do
|
||||
if v.bucket == bucket then
|
||||
curr_bucket_pool[#curr_bucket_pool + 1] = v.id
|
||||
end
|
||||
return curr_bucket_pool
|
||||
else
|
||||
return false
|
||||
end
|
||||
return curr_bucket_pool
|
||||
end
|
||||
|
||||
---Will return an array of all the entities inside the current bucket
|
||||
@@ -322,16 +313,12 @@ end
|
||||
---@return table|boolean
|
||||
function QBCore.Functions.GetEntitiesInBucket(bucket)
|
||||
local curr_bucket_pool = {}
|
||||
if QBCore.Entity_Buckets and next(QBCore.Entity_Buckets) then
|
||||
for _, v in pairs(QBCore.Entity_Buckets) do
|
||||
if v.bucket == bucket then
|
||||
curr_bucket_pool[#curr_bucket_pool + 1] = v.id
|
||||
end
|
||||
for _, v in pairs(QBCore.Entity_Buckets) do
|
||||
if v.bucket == bucket then
|
||||
curr_bucket_pool[#curr_bucket_pool + 1] = v.id
|
||||
end
|
||||
return curr_bucket_pool
|
||||
else
|
||||
return false
|
||||
end
|
||||
return curr_bucket_pool
|
||||
end
|
||||
|
||||
---Server side vehicle creation with optional callback
|
||||
@@ -347,14 +334,24 @@ function QBCore.Functions.SpawnVehicle(source, model, coords, warp)
|
||||
if not coords then coords = GetEntityCoords(ped) end
|
||||
local heading = coords.w and coords.w or 0.0
|
||||
local veh = CreateVehicle(model, coords.x, coords.y, coords.z, heading, true, true)
|
||||
while not DoesEntityExist(veh) do Wait(0) end
|
||||
local t = 0
|
||||
while not DoesEntityExist(veh) and t < 1000 do
|
||||
Wait(0)
|
||||
t += 1
|
||||
end
|
||||
if warp then
|
||||
while GetVehiclePedIsIn(ped) ~= veh do
|
||||
t = 0
|
||||
while GetVehiclePedIsIn(ped) ~= veh and t < 100 do
|
||||
Wait(0)
|
||||
t += 1
|
||||
TaskWarpPedIntoVehicle(ped, veh, -1)
|
||||
end
|
||||
end
|
||||
while NetworkGetEntityOwner(veh) ~= source do Wait(0) end
|
||||
t = 0
|
||||
while NetworkGetEntityOwner(veh) ~= source and t < 1000 do
|
||||
Wait(0)
|
||||
t += 1
|
||||
end
|
||||
return veh
|
||||
end
|
||||
|
||||
@@ -373,7 +370,11 @@ function QBCore.Functions.CreateAutomobile(source, model, coords, warp)
|
||||
local heading = coords.w and coords.w or 0.0
|
||||
local CreateAutomobile = `CREATE_AUTOMOBILE`
|
||||
local veh = Citizen.InvokeNative(CreateAutomobile, model, coords, heading, true, true)
|
||||
while not DoesEntityExist(veh) do Wait(0) end
|
||||
local t = 0
|
||||
while not DoesEntityExist(veh) and t < 1000 do
|
||||
Wait(0)
|
||||
t += 1
|
||||
end
|
||||
if warp then TaskWarpPedIntoVehicle(GetPlayerPed(source), veh, -1) end
|
||||
return veh
|
||||
end
|
||||
@@ -395,7 +396,11 @@ function QBCore.Functions.CreateVehicle(source, model, vehtype, coords, warp)
|
||||
if not coords then coords = GetEntityCoords(GetPlayerPed(source)) end
|
||||
local heading = coords.w and coords.w or 0.0
|
||||
local veh = CreateVehicleServerSetter(model, vehtype, coords, heading)
|
||||
while not DoesEntityExist(veh) do Wait(0) end
|
||||
local t = 0
|
||||
while not DoesEntityExist(veh) and t < 1000 do
|
||||
Wait(0)
|
||||
t += 1
|
||||
end
|
||||
if warp then TaskWarpPedIntoVehicle(GetPlayerPed(source), veh, -1) end
|
||||
return veh
|
||||
end
|
||||
@@ -408,9 +413,11 @@ function PaycheckInterval()
|
||||
CreateThread(function()
|
||||
for _, Player in pairs(QBCore.Players) do
|
||||
if Player then
|
||||
local payment = QBShared.Jobs[Player.PlayerData.job.name]['grades'][tostring(Player.PlayerData.job.grade.level)].payment
|
||||
local jobData = QBCore.Shared.Jobs[Player.PlayerData.job.name]
|
||||
local gradeData = jobData and jobData['grades'][tostring(Player.PlayerData.job.grade.level)]
|
||||
local payment = gradeData and gradeData.payment
|
||||
if not payment then payment = Player.PlayerData.job.payment end
|
||||
if Player.PlayerData.job and payment > 0 and (QBShared.Jobs[Player.PlayerData.job.name].offDutyPay or Player.PlayerData.job.onduty) then
|
||||
if Player.PlayerData.job and payment > 0 and (QBCore.Shared.Jobs[Player.PlayerData.job.name].offDutyPay or Player.PlayerData.job.onduty) then
|
||||
if QBCore.Config.Money.PayCheckSociety then
|
||||
local account = exports['qb-banking']:GetAccountBalance(Player.PlayerData.job.name)
|
||||
if account ~= 0 then
|
||||
@@ -463,7 +470,9 @@ function QBCore.Functions.TriggerClientCallback(name, source, ...)
|
||||
|
||||
if cb == nil then
|
||||
Citizen.Await(QBCore.ClientCallbacks[name .. source].promise)
|
||||
return QBCore.ClientCallbacks[name .. source].promise.value
|
||||
local value = QBCore.ClientCallbacks[name .. source].promise.value
|
||||
QBCore.ClientCallbacks[name .. source] = nil
|
||||
return value
|
||||
end
|
||||
end
|
||||
|
||||
@@ -538,7 +547,7 @@ function QBCore.Functions.Kick(source, reason, setKickReason, deferrals)
|
||||
for _ = 0, 4 do
|
||||
while true do
|
||||
if source then
|
||||
if GetPlayerPing(source) >= 0 then
|
||||
if GetPlayerPing(source) < 0 then
|
||||
break
|
||||
end
|
||||
CreateThread(function()
|
||||
@@ -723,27 +732,8 @@ function QBCore.Functions.Notify(source, text, type, length)
|
||||
TriggerClientEvent('QBCore:Notify', source, text, type, length)
|
||||
end
|
||||
|
||||
---???? ... ok
|
||||
---@param source any
|
||||
---@param data any
|
||||
---@param pattern any
|
||||
---@return boolean
|
||||
function QBCore.Functions.PrepForSQL(source, data, pattern)
|
||||
data = tostring(data)
|
||||
local src = source
|
||||
local player = QBCore.Functions.GetPlayer(src)
|
||||
local result = string.match(data, pattern)
|
||||
if not result or string.len(result) ~= string.len(data) then
|
||||
TriggerEvent('qb-log:server:CreateLog', 'anticheat', 'SQL Exploit Attempted', 'red', string.format('%s attempted to exploit SQL!', player.PlayerData.license))
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
for functionName, func in pairs(QBCore.Functions) do
|
||||
if type(func) == 'function' then
|
||||
exports(functionName, func)
|
||||
end
|
||||
end
|
||||
-- Access a specific function directly:
|
||||
-- exports['qb-core']:Notify(source, 'Hello Player!')
|
||||
|
||||
Reference in New Issue
Block a user