Remove example scripts and update core logic

Deleted all files in the examples directory to clean up unused or test scripts. Updated fxmanifest.lua to enable ox_lib initialization. Improved error handling and entity tracking in utility functions, added prop removal, and made minor localization and code style adjustments throughout the codebase. Significant reword of inventory module, notification module, and framework module. Added support for wasabi_uikit, added support for keep-progressbars,
This commit is contained in:
MrNewb committed 2025-12-14 16:22:35 -05:00
1 parent c40a260ea2
commit 343af95794
100 files changed
+2403 -2755

No files matched your search

+174 -88
View File
@@ -13,16 +13,17 @@ local cachedItemList = nil
--- @description This will return the name of the framework in use
--- @return string
Framework.GetFrameworkName = function()
return 'es_extended'
print("This is deprecated, please use Framework.GetResourceName() instead.")
return Framework.GetResourceName()
end
---This will get the name of the in use resource.
---@return string
---@description This will get the name of the in use resource.
--- @return string
Framework.GetResourceName = function()
return 'es_extended'
end
--- @description This is an internal function, its here to attempt to emulate qbs shared items mainly
---@description This is an internal function, its here to attempt to emulate qbs shared items mainly, do not use this outside of bridge.
Framework.ItemList = function()
if cachedItemList then return cachedItemList end
local items = ESX.Items
@@ -46,9 +47,9 @@ Framework.ItemList = function()
return cachedItemList
end
--- @description This will return if the player is an admin in the framework
--- @param src any
--- @return boolean
---@description This will return if the player is an admin in the framework.
---@param src number
---@return boolean
Framework.GetIsFrameworkAdmin = function(src)
if not src then return false end
local xPlayer = Framework.GetPlayer(src)
@@ -58,7 +59,8 @@ Framework.GetIsFrameworkAdmin = function(src)
return false
end
--- @description This will get the players birth date
---@description Returns the player date of birth.
--- @param src number
--- @return string|nil
Framework.GetPlayerDob = function(src)
local xPlayer = Framework.GetPlayer(src)
@@ -99,7 +101,7 @@ Framework.GetPlayerName = function(src)
return xPlayer.variables.firstName, xPlayer.variables.lastName
end
--- @description This will return a table of all logged in players
---@description This will return a table of all logged in players
--- @return table
Framework.GetPlayers = function()
local players = ESX.GetExtendedPlayers()
@@ -110,14 +112,16 @@ Framework.GetPlayers = function()
return playerList
end
--- @description This will return a table of items matching the specified name and if passed metadata from the player's inventory
---@description Returns a table of items matching the specified name and if passed metadata from the player's inventory.
--- This is an internal function and should not be used outside of bridge, use the Inventory module instead when dealing with items.
--- @param src number
--- @param item string
--- @param _ table
--- @return table|nil returns {name = v.name, count = v.amount, metadata = v.info, slot = v.slot}
Framework.GetItem = function(src, item, _)
--- @param metadata table
--- @return table {name, count, metadata, slot}
Framework.GetItem = function(src, item, metadata)
print("ESX does not support item metadata searches, please ensure you are using a supported inventory system or that you have the correct start order.")
local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return end
if not xPlayer then return {} end
local playerItems = xPlayer.getInventory()
local repackedTable = {}
for _, v in pairs(playerItems) do
@@ -125,40 +129,57 @@ Framework.GetItem = function(src, item, _)
table.insert(repackedTable, {
name = v.name,
count = v.count,
--metadata = v.metadata,
--slot = v.slot,
metadata = {}, -- ESX does not support item metadata
slot = 0, -- ESX does not support item slots
})
end
end
return repackedTable
end
--- @param src number
---@description This will return a table with the item info, {name, label, stack, weight, description, image}
--- This is an internal function and should not be used outside of bridge, use the Inventory module instead when dealing with items.
--- @param item string
--- @param _ table
--- @return number returns the count of the item in the players inventory, if not found will return 0.
--- If metadata is passed it will find the matching items count (esx_core does not feature metadata items)
Framework.GetItemCount = function(src, item, _)
--- @return table {name, label, stack, weight, description, image}
Framework.GetItemInfo = function(item)
local items = Framework.ItemList()
if not items[item] then return {} end
return {name = item, label = items[item].label, stack = false, weight = items[item].weight, description = items[item].description, image = items[item].image}
end
---@description This will return the count of the item in the players inventory, if not found will return 0.
--- This is an internal function and should not be used outside of bridge, use the Inventory module instead when dealing with items.
---@param src number
---@param item string
---@param metadata table (optional)
---@return number
Framework.GetItemCount = function(src, item, metadata)
if metadata then
print("ESX does not support item metadata searches, please ensure you are using a supported inventory system or that you have the correct start order.")
end
local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return end
if not xPlayer then return 0 end
return xPlayer.getInventoryItem(item).count
end
--- @description This will return true if the player has the item, false otherwise
---@description This will return a boolean if the player has the item.
--- This is an internal function and should not be used outside of bridge, use the Inventory module instead when dealing with items.
--- @param src number
--- @param item string
--- @return boolean returns true if the player has the item, false otherwise.
--- @return boolean
Framework.HasItem = function(src, item)
local getCount = Framework.GetItemCount(src, item, nil)
return getCount > 0
end
--- @description This will return the player's inventory as a table
--- @param src number
--- @return table | nil returns the player's inventory as a table in format: {name = v.name, count = v.amount, metadata = v.info, slot = v.slot}
---@description Returns the entire inventory of the player as a table.
--- This is an internal function and should not be used outside of bridge, use the Inventory module instead when dealing with items.
---@param src number
---@return table {name, count, metadata, slot}
Framework.GetPlayerInventory = function(src)
print("ESX does not support item metadata or slots, please ensure you are using a supported inventory system or that you have the correct start order.")
local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return end
if not xPlayer then return {} end
local playerItems = xPlayer.getInventory()
local repackedTable = {}
for _, v in pairs(playerItems) do
@@ -166,15 +187,25 @@ Framework.GetPlayerInventory = function(src)
table.insert(repackedTable, {
name = v.name,
count = v.count,
--metadata = v.metadata,
--slot = v.slot,
metadata = {}, -- ESX does not support item metadata
slot = 0, -- ESX does not support item slots
})
end
end
return repackedTable
end
--- @description Adds the specified metadata key and number value to the player's data.
---@description This will return the item data for the specified slot.
--- This is an internal function and should not be used outside of bridge, use the Inventory module instead when dealing with items.
--- @param src number
--- @param slot number
--- @return table {name, label, weight, count, metadata, slot, stack, description}
Framework.GetItemBySlot = function(src, slot)
print("ESX does not support item slots, please ensure you are using a supported inventory system or that you have the correct start order.")
return {} -- ESX does not support item slots
end
---@description Adds the specified metadata key and number value to the player's data.
--- @param src number
--- @param metadata string
--- @param value any
@@ -186,8 +217,7 @@ Framework.SetPlayerMetadata = function(src, metadata, value)
return true
end
-- Framework.GetMetadata(src, metadata)
--- @description Gets the specified metadata key to the player's data.
---@description Gets the specified metadata key to the player's data.
--- @param src number
--- @param metadata string
--- @return any|nil
@@ -197,7 +227,7 @@ Framework.GetPlayerMetadata = function(src, metadata)
return xPlayer.getMeta(metadata) or false
end
--- @description This will return the specified status column of the player.
---@description This is an internal function and should not be used outside of bridge, this is only present in the esx portion.
--- @param src number
--- @param column string
--- @return string|nil
@@ -213,16 +243,16 @@ Framework.GetStatus = function(src, column)
return xPlayer.get(column) or nil
end
--- @description This will return a boolean if the player is dead or in last stand
---@description This will return a boolean if the player is dead or in last stand.
--- @param src number
--- @return boolean|nil
--- @return boolean
Framework.GetIsPlayerDead = function(src)
local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return end
if not xPlayer then return false end
return xPlayer.get("is_dead") or false
end
--- @description This will revive a player, if the player is dead or in last stand
---@description This will revive a player, if the player is dead or in last stand.
--- @param src number
--- @return boolean
Framework.RevivePlayer = function(src)
@@ -254,13 +284,13 @@ Framework.AddHunger = function(src, value)
return levelForEsx
end
--- @description This will get the hunger of a player (ESX we get the percent of the status)
---@description This will get the hunger of a player
--- @param src number
--- @return number | nil
--- @return number
Framework.GetHunger = function(src)
local status = Framework.GetStatus(src, "status")
if not status then return end
if type(status) ~= "table" then return end
if not status then return 0 end
if type(status) ~= "table" then return 0 end
for _, entry in ipairs(status) do
if entry.name == "hunger" then
return math.floor((entry.percent) + 0.5) or 0
@@ -268,13 +298,13 @@ Framework.GetHunger = function(src)
end
end
--- @description This will get the thirst of a player (ESX we get the percent of the status)
---@description This will get the thirst of a player
--- @param src any
--- @return number | nil
--- @return number
Framework.GetThirst = function(src)
local status = Framework.GetStatus(src, "status")
if not status then return nil end
if type(status) ~= "table" then return end
if not status then return 0 end
if type(status) ~= "table" then return 0 end
for _, entry in ipairs(status) do
if entry.name == "thirst" then
return math.floor((entry.percent) + 0.5) or 0
@@ -282,16 +312,17 @@ Framework.GetThirst = function(src)
end
end
--- @description This will get the phone number of a player
---@description Returns the phone number of the player.
--- @param src number
--- @return string | nil return the phone number of the player
--- @return string | nil
Framework.GetPlayerPhone = function(src)
local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return end
return xPlayer.get("phone_number")
end
---@deprecated This will return the job name, label, grade name, and grade level of the player.
---@description This will return the job name, label, grade name, and grade level of the player.
---@deprecated
---@param src number
---@return string | nil
---@return string | nil
@@ -304,13 +335,12 @@ Framework.GetPlayerJob = function(src)
return job.name, job.label, job.grade_label, job.grade
end
--- @description This will return the players job name, job label, job grade label job grade level,
--- boss status, and duty status in a table
---@description This will return the players job name, job label, job grade label job grade level, boss status, and duty status in a table
--- @param src number
--- @return table | nil
--- @return table {jobName, jobLabel, gradeName, gradeLabel, gradeRank, boss, onDuty}
Framework.GetPlayerJobData = function(src)
local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return end
if not xPlayer then return {} end
local job = xPlayer.getJob()
local isBoss = (job.grade_name == "boss")
return {
@@ -324,9 +354,9 @@ Framework.GetPlayerJobData = function(src)
}
end
--- @description This will return the players duty status, true if on duty false otherwise
---@description Returns the players duty status.
--- @param src number
--- @return boolean return the players duty status
--- @return boolean
Framework.GetPlayerDuty = function(src)
local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return false end
@@ -335,7 +365,7 @@ Framework.GetPlayerDuty = function(src)
return true
end
--- @description This will toggle a players duty status
---@description This will toggle a players duty status
--- @param src number
--- @param status boolean
--- @return boolean
@@ -348,95 +378,131 @@ Framework.SetPlayerDuty = function(src, status)
return true
end
--- @description This will get a table of player sources that have the specified job name
---@description Returns the gang name of the player.
---@param src number
---@return string | nil
Framework.GetPlayerGang = function(src)
print("ESX does not support gangs, please ensure you are using a supported gang system or that you have the correct start order.")
return
end
---@description This will get a table of player sources that have the specified job name.
--- @param job string
--- @return table
Framework.GetPlayersByJob = function(job)
return Framework.GetPlayerSourcesByJob(job) or {}
end
--- @description This will set the player's job to the specified name and grade
---@description Sets the player's job to the specified name and grade.
--- @param src number
--- @param name string
--- @param grade string
--- @return nil
Framework.SetPlayerJob = function(src, name, grade)
local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return end
if not ESX.DoesJobExist(name, grade) then
Prints.Error("Job Does Not Exsist In Framework :NAME " .. name .. " Grade:" .. grade)
print("^6 Job Does Not Exsist In Framework :NAME " .. name .. " Grade:" .. grade .. " ^0 ")
return
end
xPlayer.setJob(name, grade, true)
return true
end
--- @description This will add money based on the type of account (money/bank)
---@description This will add money based on the type of account (money/bank)
--- @param src number
--- @param _type string
--- @param amount number
--- @return boolean | nil
--- @return boolean
Framework.AddAccountBalance = function(src, _type, amount)
local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return end
if not xPlayer then return false end
if _type == 'cash' then _type = 'money' end
if amount <= 0 then return false end
xPlayer.addAccountMoney(_type, amount)
return true
end
--- @description This will remove money based on the type of account (money/bank)
---@description This will remove money based on the type of account (money/bank)
--- @param src number
--- @param _type string
--- @param amount number
--- @return boolean | nil
--- @return boolean
Framework.RemoveAccountBalance = function(src, _type, amount)
local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return end
if not xPlayer then return false end
if _type == 'cash' then _type = 'money' end
if amount <= 0 then return false end
local accountVal = Framework.GetAccountBalance(src, _type)
if accountVal < amount then return false end
xPlayer.removeAccountMoney(_type, amount)
return true
end
--- @description This will get the account balance based on the type of account (money/bank)
---@description This will get money based on the type of account (money/bank)
--- @param src number
--- @param _type string
--- @return string | nil
--- @return number
Framework.GetAccountBalance = function(src, _type)
local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return end
if not xPlayer then return 0 end
if _type == 'cash' then _type = 'money' end
return xPlayer.getAccount(_type).money
local balance = xPlayer.getAccount(_type).money or 0
if balance <= 0 then return 0 end
return balance
end
--- @description Adds the specified item to the player's inventory
--- @param src number
--- @param item string
--- @param amount number
--- @param slot number
--- @param metadata table
--- @return boolean | nil
Framework.AddItem = function(src, item, amount, slot, metadata)
---@description This will add an item, and return true or false based on success
--- This is an internal function and should not be used outside of bridge, use the Inventory module instead when dealing with items.
---@param src number
---@param item string
---@param count number
---@param slot number (optional)
---@param metadata table (optional)
---@return boolean
Framework.AddItem = function(src, item, count, slot, metadata)
if slot then print("ESX does not support item slots, please ensure you are using a supported inventory system or that you have the correct start order.") end
if metadata then print("ESX does not support item metadata, please ensure you are using a supported inventory system or that you have the correct start order.") end
local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return end
xPlayer.addInventoryItem(item, amount)
if not xPlayer then return false end
xPlayer.addInventoryItem(item, count)
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, { action = "add", item = item, count = count, slot = slot, metadata = metadata })
return true
end
--- @description Removes the specified item from the player's inventory
---@description Removes the specified item from the player's inventory.
--- This is an internal function and should not be used outside of bridge, use the Inventory module instead when dealing with items.
--- @param src number
--- @param item string
--- @param amount number
--- @param slot number
--- @param metadata table
---@return boolean | nil
--- @param slot number (optional)
--- @param metadata table (optional)
--- @return boolean
Framework.RemoveItem = function(src, item, amount, slot, metadata)
if slot then
print("ESX does not support item slots, please ensure you are using a supported inventory system or that you have the correct start order.")
end
if metadata then
print("ESX does not support item metadata, please ensure you are using a supported inventory system or that you have the correct start order.")
end
local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return end
if not xPlayer then return false end
xPlayer.removeInventoryItem(item, amount)
return true
end
--- @description This will get all owned vehicles for the player
---@description Sets the metadata for the specified item in the player's inventory.
--- This is an internal function and should not be used outside of bridge, use the Inventory module instead when dealing with items.
--- @param src number
--- @param item string
--- @param slot number
--- @param metadata table
--- @return boolean
Framework.SetMetadata = function(src, item, slot, metadata)
print("ESX does not support item metadata, please ensure you are using a supported inventory system or that you have the correct start order.")
return false
end
---@description This will get all owned vehicles for the player
--- @param src number
--- @return table
Framework.GetOwnedVehicles = function(src)
@@ -452,7 +518,7 @@ Framework.GetOwnedVehicles = function(src)
return vehicles
end
--- @description Registers a usable item with a callback function
---@description Registers a usable item with a callback function.
--- @param itemName string
--- @param cb function
Framework.RegisterUsableItem = function(itemName, cb)
@@ -465,6 +531,8 @@ Framework.RegisterUsableItem = function(itemName, cb)
ESX.RegisterUsableItem(itemName, func)
end
---@description Event handler for when a player is loaded in ESX framework
---@param src number
RegisterNetEvent("esx:playerLoaded", function(src)
src = src or source
TriggerEvent("community_bridge:Server:OnPlayerLoaded", src)
@@ -473,32 +541,50 @@ RegisterNetEvent("esx:playerLoaded", function(src)
Framework.AddJobCount(src, jobData.jobName)
end)
---@description Event handler for when a player logs out in ESX framework
---@param src number
RegisterNetEvent("esx:playerLogout", function(src)
src = src or source
TriggerEvent("community_bridge:Server:OnPlayerUnload", src)
end)
---@description Event handler for when a player's job is updated in ESX framework
---@param src number
---@param job table
---@param lastJob table
RegisterNetEvent("esx:setJob", function(src, job, lastJob)
src = src or source
if not job or not lastJob then return end
TriggerEvent("community_bridge:Server:OnPlayerJobChange", src, job.name)
end)
---@description Event handler for when a player disconnects from the server
AddEventHandler("playerDropped", function()
local src = source
TriggerEvent("community_bridge:Server:OnPlayerUnload", src)
end)
---@description Callback to get framework jobs list
---@param source number
Callback.Register('community_bridge:Callback:GetFrameworkJobs', function(source)
return Framework.GetFrameworkJobs() or {}
end)
-- This is linked to an internal function, its an attempt to standardize the item list across frameworks.
---@description This is linked to an internal function, its an attempt to standardize the item list across frameworks.
---@param source number
Callback.Register('community_bridge:Callback:GetFrameworkItems', function(source)
return Framework.ItemList() or {}
end)
Framework.Commands = {}
---@description Adds a command to the ESX framework
---@param name string
---@param help string
---@param arguments table
---@param argsrequired boolean
---@param callback function
---@param permission string
---@param ... any
Framework.Commands.Add = function(name, help, arguments, argsrequired, callback, permission, ...)
ESX.RegisterCommand(name, permission, function(xPlayer, args, showError)
callback(xPlayer, args)