mirror of
https://github.com/qbcore-fivem/qb-core.git
synced 2026-08-28 17:01:16 +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:
+1
-1
@@ -29,7 +29,7 @@ local function changeText(text, position)
|
||||
end
|
||||
|
||||
local function keyPressed()
|
||||
CreateThread(function() -- Not sure if a thread is needed but why not eh?
|
||||
CreateThread(function()
|
||||
SendNUIMessage({
|
||||
action = 'KEY_PRESSED',
|
||||
})
|
||||
|
||||
+10
-19
@@ -1,6 +1,3 @@
|
||||
-- Player load and unload handling
|
||||
-- New method for checking if logged in across all scripts (optional)
|
||||
-- if LocalPlayer.state['isLoggedIn'] then
|
||||
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
|
||||
ShutdownLoadingScreenNui()
|
||||
LocalPlayer.state:set('isLoggedIn', true, false)
|
||||
@@ -17,6 +14,7 @@ RegisterNetEvent('QBCore:Client:PvpHasToggled', function(pvp_state)
|
||||
SetCanAttackFriendly(PlayerPedId(), pvp_state, false)
|
||||
NetworkSetFriendlyFireOption(pvp_state)
|
||||
end)
|
||||
|
||||
-- Teleport Commands
|
||||
|
||||
RegisterNetEvent('QBCore:Command:TeleportToPlayer', function(coords)
|
||||
@@ -182,30 +180,23 @@ end)
|
||||
|
||||
-- Other stuff
|
||||
|
||||
RegisterNetEvent('QBCore:Player:SetPlayerData', function(val)
|
||||
QBCore.PlayerData = val
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Player:UpdatePlayerDataField', function(key, val)
|
||||
if QBCore.PlayerData and key then
|
||||
RegisterNetEvent('QBCore:Client:OnPlayerUpdated', function(key, val)
|
||||
if key == 'all' then
|
||||
QBCore.PlayerData = val
|
||||
TriggerEvent('QBCore:Player:SetPlayerData', val)
|
||||
TriggerEvent('QBCore:Client:OnJobUpdate', val.job)
|
||||
TriggerEvent('QBCore:Client:OnGangUpdate', val.gang)
|
||||
elseif QBCore.PlayerData and key then
|
||||
QBCore.PlayerData[key] = val
|
||||
if key == 'job' then TriggerEvent('QBCore:Client:OnJobUpdate', val) end
|
||||
if key == 'gang' then TriggerEvent('QBCore:Client:OnGangUpdate', val) end
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Player:UpdatePlayerData', function()
|
||||
TriggerServerEvent('QBCore:UpdatePlayer')
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Notify', function(text, type, length, icon)
|
||||
QBCore.Functions.Notify(text, type, length, icon)
|
||||
end)
|
||||
|
||||
-- This event is exploitable and should not be used. It has been deprecated, and will be removed soon.
|
||||
RegisterNetEvent('QBCore:Client:UseItem', function(item)
|
||||
QBCore.Debug(string.format('%s triggered QBCore:Client:UseItem by ID %s with the following data. This event is deprecated due to exploitation, and will be removed soon. Check qb-inventory for the right use on this event.', GetInvokingResource(), GetPlayerServerId(PlayerId())))
|
||||
QBCore.Debug(item)
|
||||
end)
|
||||
|
||||
RegisterNUICallback('getNotifyConfig', function(_, cb)
|
||||
cb(QBCore.Config.Notify)
|
||||
end)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
QBCore.PlayerData = {}
|
||||
QBCore.Functions = {}
|
||||
|
||||
-- Callbacks
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
QBCore = {}
|
||||
QBCore.PlayerData = {}
|
||||
QBCore.Config = QBConfig
|
||||
QBCore.Shared = QBShared
|
||||
QBCore.ClientCallbacks = {}
|
||||
QBCore.ServerCallbacks = {}
|
||||
|
||||
-- Get the full QBCore object (default behavior):
|
||||
-- local QBCore = GetCoreObject()
|
||||
|
||||
-- Get only specific parts of QBCore:
|
||||
-- local QBCore = GetCoreObject({'Players', 'Config'})
|
||||
|
||||
local function GetCoreObject(filters)
|
||||
if not filters then return QBCore end
|
||||
local results = {}
|
||||
for i = 1, #filters do
|
||||
local key = filters[i]
|
||||
if QBCore[key] then
|
||||
results[key] = QBCore[key]
|
||||
end
|
||||
end
|
||||
return results
|
||||
end
|
||||
exports('GetCoreObject', GetCoreObject)
|
||||
|
||||
local function GetSharedItems()
|
||||
return QBShared.Items
|
||||
end
|
||||
exports('GetSharedItems', GetSharedItems)
|
||||
|
||||
local function GetSharedVehicles()
|
||||
return QBShared.Vehicles
|
||||
end
|
||||
exports('GetSharedVehicles', GetSharedVehicles)
|
||||
|
||||
local function GetSharedWeapons()
|
||||
return QBShared.Weapons
|
||||
end
|
||||
exports('GetSharedWeapons', GetSharedWeapons)
|
||||
|
||||
local function GetSharedJobs()
|
||||
return QBShared.Jobs
|
||||
end
|
||||
exports('GetSharedJobs', GetSharedJobs)
|
||||
|
||||
local function GetSharedGangs()
|
||||
return QBShared.Gangs
|
||||
end
|
||||
exports('GetSharedGangs', GetSharedGangs)
|
||||
Reference in New Issue
Block a user