mirror of
https://github.com/qbcore-fivem/qb-core.git
synced 2026-09-04 16:23:21 +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:
+21
-69
@@ -3,11 +3,11 @@ local function SetMethod(methodName, handler)
|
||||
if type(methodName) ~= 'string' then
|
||||
return false, 'invalid_method_name'
|
||||
end
|
||||
|
||||
if QBCore.Functions[methodName] ~= nil then
|
||||
return false, 'method_exists'
|
||||
end
|
||||
QBCore.Functions[methodName] = handler
|
||||
|
||||
TriggerEvent('QBCore:Server:UpdateObject')
|
||||
|
||||
return true, 'success'
|
||||
end
|
||||
|
||||
@@ -19,11 +19,11 @@ local function SetField(fieldName, data)
|
||||
if type(fieldName) ~= 'string' then
|
||||
return false, 'invalid_field_name'
|
||||
end
|
||||
|
||||
if QBCore[fieldName] ~= nil then
|
||||
return false, 'field_exists'
|
||||
end
|
||||
QBCore[fieldName] = data
|
||||
|
||||
TriggerEvent('QBCore:Server:UpdateObject')
|
||||
|
||||
return true, 'success'
|
||||
end
|
||||
|
||||
@@ -52,32 +52,16 @@ exports('AddJob', AddJob)
|
||||
|
||||
-- Multiple Add Jobs
|
||||
local function AddJobs(jobs)
|
||||
local shouldContinue = true
|
||||
local message = 'success'
|
||||
local errorItem = nil
|
||||
|
||||
for key, value in pairs(jobs) do
|
||||
if type(key) ~= 'string' then
|
||||
message = 'invalid_job_name'
|
||||
shouldContinue = false
|
||||
errorItem = jobs[key]
|
||||
break
|
||||
end
|
||||
|
||||
if QBCore.Shared.Jobs[key] then
|
||||
message = 'job_exists'
|
||||
shouldContinue = false
|
||||
errorItem = jobs[key]
|
||||
break
|
||||
end
|
||||
|
||||
if type(key) ~= 'string' then return false, 'invalid_job_name', value end
|
||||
if QBCore.Shared.Jobs[key] then return false, 'job_exists', value end
|
||||
end
|
||||
for key, value in pairs(jobs) do
|
||||
QBCore.Shared.Jobs[key] = value
|
||||
end
|
||||
|
||||
if not shouldContinue then return false, message, errorItem end
|
||||
TriggerClientEvent('QBCore:Client:OnSharedUpdateMultiple', -1, 'Jobs', jobs)
|
||||
TriggerEvent('QBCore:Server:UpdateObject')
|
||||
return true, message, nil
|
||||
return true, 'success', nil
|
||||
end
|
||||
|
||||
QBCore.Functions.AddJobs = AddJobs
|
||||
@@ -162,32 +146,16 @@ exports('UpdateItem', UpdateItem)
|
||||
|
||||
-- Multiple Add Items
|
||||
local function AddItems(items)
|
||||
local shouldContinue = true
|
||||
local message = 'success'
|
||||
local errorItem = nil
|
||||
|
||||
for key, value in pairs(items) do
|
||||
if type(key) ~= 'string' then
|
||||
message = 'invalid_item_name'
|
||||
shouldContinue = false
|
||||
errorItem = items[key]
|
||||
break
|
||||
end
|
||||
|
||||
if QBCore.Shared.Items[key] then
|
||||
message = 'item_exists'
|
||||
shouldContinue = false
|
||||
errorItem = items[key]
|
||||
break
|
||||
end
|
||||
|
||||
if type(key) ~= 'string' then return false, 'invalid_item_name', value end
|
||||
if QBCore.Shared.Items[key] then return false, 'item_exists', value end
|
||||
end
|
||||
for key, value in pairs(items) do
|
||||
QBCore.Shared.Items[key] = value
|
||||
end
|
||||
|
||||
if not shouldContinue then return false, message, errorItem end
|
||||
TriggerClientEvent('QBCore:Client:OnSharedUpdateMultiple', -1, 'Items', items)
|
||||
TriggerEvent('QBCore:Server:UpdateObject')
|
||||
return true, message, nil
|
||||
return true, 'success', nil
|
||||
end
|
||||
|
||||
QBCore.Functions.AddItems = AddItems
|
||||
@@ -235,32 +203,16 @@ exports('AddGang', AddGang)
|
||||
|
||||
-- Multiple Add Gangs
|
||||
local function AddGangs(gangs)
|
||||
local shouldContinue = true
|
||||
local message = 'success'
|
||||
local errorItem = nil
|
||||
|
||||
for key, value in pairs(gangs) do
|
||||
if type(key) ~= 'string' then
|
||||
message = 'invalid_gang_name'
|
||||
shouldContinue = false
|
||||
errorItem = gangs[key]
|
||||
break
|
||||
end
|
||||
|
||||
if QBCore.Shared.Gangs[key] then
|
||||
message = 'gang_exists'
|
||||
shouldContinue = false
|
||||
errorItem = gangs[key]
|
||||
break
|
||||
end
|
||||
|
||||
if type(key) ~= 'string' then return false, 'invalid_gang_name', value end
|
||||
if QBCore.Shared.Gangs[key] then return false, 'gang_exists', value end
|
||||
end
|
||||
for key, value in pairs(gangs) do
|
||||
QBCore.Shared.Gangs[key] = value
|
||||
end
|
||||
|
||||
if not shouldContinue then return false, message, errorItem end
|
||||
TriggerClientEvent('QBCore:Client:OnSharedUpdateMultiple', -1, 'Gangs', gangs)
|
||||
TriggerEvent('QBCore:Server:UpdateObject')
|
||||
return true, message, nil
|
||||
return true, 'success', nil
|
||||
end
|
||||
|
||||
QBCore.Functions.AddGangs = AddGangs
|
||||
|
||||
Reference in New Issue
Block a user