es_extended framework code cleanup

This commit is contained in:
solaire-fivem committed 2025-08-31 18:41:12 +01:00
1 parent 957e2e2ff6
commit f5017792e3
2 files changed
+196 -202

No files matched your search

+62 -61
View File
@@ -1,13 +1,14 @@
---@diagnostic disable: duplicate-set-field ---@diagnostic disable: duplicate-set-field
if GetResourceState('es_extended') ~= 'started' then return end if GetResourceState('es_extended') ~= 'started' then return end
ESX = exports["es_extended"]:getSharedObject() ESX = exports.es_extended:getSharedObject()
Callback = Callback or Require("lib/utility/shared/callbacks.lua") Callback = Callback or Require("lib/utility/shared/callbacks.lua")
Framework = Framework or {} Framework = Framework or {}
local cachedItemList = nil local cachedItemList = nil
-- 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
Framework.ItemList = function() Framework.ItemList = function()
if cachedItemList then return cachedItemList end if cachedItemList then return cachedItemList end
local items = Callback.Trigger('community_bridge:Callback:GetFrameworkItems', false) local items = Callback.Trigger('community_bridge:Callback:GetFrameworkItems', false)
@@ -15,98 +16,99 @@ Framework.ItemList = function()
return cachedItemList return cachedItemList
end end
---This will get the name of the framework being used (if a supported framework). --- @description This will get the name of the framework being used (if a supported framework).
---@return string --- @return string
Framework.GetFrameworkName = function() Framework.GetFrameworkName = function()
return 'es_extended' return 'es_extended'
end end
---This will return true if the player is loaded, false otherwise. --- @description This will return true if the player is loaded, false otherwise.
---This could be useful in scripts that rely on player loaded events and offer a debug mode to hit this function. --- This could be useful in scripts that rely on player loaded events and offer a debug mode to hit this function
---@return boolean --- @return boolean
Framework.GetIsPlayerLoaded = function() Framework.GetIsPlayerLoaded = function()
return ESX.IsPlayerLoaded() return ESX.IsPlayerLoaded()
end end
---This will return a table of the player data, this will be in the framework format. --- @description This will return a table of the player data, this will be in the framework format
---This is mainly for internal bridge use and should be avoided. --- This is mainly for internal bridge use and should be avoided.
---@return table --- @return table
Framework.GetPlayerData = function() Framework.GetPlayerData = function()
return ESX.GetPlayerData() return ESX.GetPlayerData()
end end
---This will return a table of all the jobs in the framework. --- @description This will return a table of all the jobs in the framework.
---@return table --- @return table
Framework.GetFrameworkJobs = function() Framework.GetFrameworkJobs = function()
local jobs = Callback.Trigger('community_bridge:Callback:GetFrameworkJobs', false) local jobs = Callback.Trigger('community_bridge:Callback:GetFrameworkJobs', false)
return jobs return jobs
end end
---This will return the players birth date --- @description This will return the players birth date
---@return string --- @return string
Framework.GetPlayerDob = function() Framework.GetPlayerDob = function()
local playerData = Framework.GetPlayerData() local playerData = Framework.GetPlayerData()
local dob = playerData.dateofbirth local dob = playerData.dateofbirth
return dob return dob
end end
---This will return the players metadata for the specified metadata key. --- @description This will return the players metadata for the specified metadata key.
---@param metadata table | string --- @param metadata table | string
---@return table | string | number | boolean ---@return table | string | number | boolean
Framework.GetPlayerMetaData = function(metadata) Framework.GetPlayerMetaData = function(metadata)
return Framework.GetPlayerData().metadata[metadata] return Framework.GetPlayerData().metadata[metadata]
end end
---This will send a notification to the player. --- @description This will send a notification to the player.
---@param message string --- @param message string
---@param type string --- @param type string
---@param time number --- @param time number
---@return nil --- @return nil
Framework.Notify = function(message, type, time) Framework.Notify = function(message, type, time)
return ESX.ShowNotification(message, type, time) return ESX.ShowNotification(message, type, time)
end end
---Will Display the help text message on the screen --- @description This will display the help text message on the screen
---@param message string --- @param message string
---@param _ unknown --- @param _ unknown
---@return nil --- @return nil
Framework.ShowHelpText = function(message, _) Framework.ShowHelpText = function(message, _)
return exports['esx_textui']:TextUI(message, "info") return exports.esx_textui:TextUI(message, "info")
end end
---This will hide the help text message on the screen --- @description This will hide the help text message on the screen
---@return nil --- @return nil
Framework.HideHelpText = function() Framework.HideHelpText = function()
return exports['esx_textui']:HideUI() return exports.esx_textui:HideUI()
end end
---This will get the players identifier (citizenid) etc. --- @description This will get the players identifier (citizenid) etc.
---@return string ---@return string
Framework.GetPlayerIdentifier = function() Framework.GetPlayerIdentifier = function()
local playerData = Framework.GetPlayerData() local playerData = Framework.GetPlayerData()
return playerData.identifier return playerData.identifier
end end
---This will get the players name (first and last). --- @description This will get the players name (first and last).
---@return string --- @return string
---@return string --- @return string
Framework.GetPlayerName = function() Framework.GetPlayerName = function()
local playerData = Framework.GetPlayerData() local playerData = Framework.GetPlayerData()
return playerData.firstName, playerData.lastName return playerData.firstName, playerData.lastName
end end
---Depricated : This will return the players job name, job label, job grade label and job grade level --- @deprecated This will return the players job name, job label, job grade label and job grade level
---@return string --- @return string returns job name
---@return string --- @return string returns job label
---@return string --- @return string returns job grade label
---@return string --- @return string returns job grade level
Framework.GetPlayerJob = function() Framework.GetPlayerJob = function()
local playerData = Framework.GetPlayerData() local playerData = Framework.GetPlayerData()
return playerData.job.name, playerData.job.label, playerData.job.grade_label, playerData.job.grade return playerData.job.name, playerData.job.label, playerData.job.grade_label, playerData.job.grade
end end
---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,
---@return table --- boss status, and duty status in a table
--- @return table
Framework.GetPlayerJobData = function() Framework.GetPlayerJobData = function()
local playerData = Framework.GetPlayerData() local playerData = Framework.GetPlayerData()
local jobData = playerData.job local jobData = playerData.job
@@ -122,34 +124,33 @@ Framework.GetPlayerJobData = function()
} }
end end
---This will return if the player has the specified item in their inventory. --- @description This will return if the player has the specified item in their inventory
---@param item string --- @param item string
---@return boolean --- @return boolean
Framework.HasItem = function(item) Framework.HasItem = function(item)
local hasItem = ESX.SearchInventory(item, true) local hasItem = ESX.SearchInventory(item, true)
return hasItem > 0 and true or false return hasItem > 0 and true or false
end end
---This will return the item count for the specified item in the players inventory. --- @description This will return the item count for the specified item in the players inventory
---@param item string --- @param item string
---@return number --- @return number
Framework.GetItemCount = function(item) Framework.GetItemCount = function(item)
local inventory = Framework.GetPlayerInventory() local inventory = Framework.GetPlayerInventory()
if not inventory then return 0 end if not inventory then return 0 end
return inventory[item].count or 0 return inventory[item].count or 0
end end
---This will return a table of the players inventory --- @description This will return a table of the players inventory
---@return table --- @return table
Framework.GetPlayerInventory = function() Framework.GetPlayerInventory = function()
local playerData = Framework.GetPlayerData() local playerData = Framework.GetPlayerData()
return playerData.inventory return playerData.inventory
end end
---This will return the players money by type, I recommend not useing this as its the client and not secure or to be trusted. --- @description This will return the players money by type, I recommend not using this as its the client and not secure or to be trusted
---Use case is for a ui or a menu I guess. --- @param _type string
---@param _type string --- @return number
---@return number
Framework.GetAccountBalance = function(_type) Framework.GetAccountBalance = function(_type)
local player = Framework.GetPlayerData() local player = Framework.GetPlayerData()
if not player then return 0 end if not player then return 0 end
@@ -163,19 +164,19 @@ Framework.GetAccountBalance = function(_type)
return 0 return 0
end end
---This will return the vehicle properties for the specified vehicle. --- @description This will return the vehicle properties for the specified vehicle
---@param vehicle number --- @param vehicle number
---@return table --- @return table
Framework.GetVehicleProperties = function(vehicle) Framework.GetVehicleProperties = function(vehicle)
if not vehicle or not DoesEntityExist(vehicle) then return {} end if not vehicle or not DoesEntityExist(vehicle) then return {} end
local vehicleProps = ESX.Game.GetVehicleProperties(vehicle) local vehicleProps = ESX.Game.GetVehicleProperties(vehicle)
return vehicleProps or {} return vehicleProps or {}
end end
---This will set the vehicle properties for the specified vehicle. --- @description This will set the vehicle properties for the specified vehicle
---@param vehicle number --- @param vehicle number
---@param properties table --- @param properties table
---@return boolean --- @return boolean
Framework.SetVehicleProperties = function(vehicle, properties) Framework.SetVehicleProperties = function(vehicle, properties)
if not vehicle or not DoesEntityExist(vehicle) then return false end if not vehicle or not DoesEntityExist(vehicle) then return false end
if not properties then return false end if not properties then return false end
@@ -203,8 +204,8 @@ Framework.SetVehicleProperties = function(vehicle, properties)
return true, ESX.Game.SetVehicleProperties(vehicle, properties) return true, ESX.Game.SetVehicleProperties(vehicle, properties)
end end
---This will get a players dead status. --- @description This will get a players dead status
---@return boolean --- @return boolean
Framework.GetIsPlayerDead = function() Framework.GetIsPlayerDead = function()
local playerData = Framework.GetPlayerData() local playerData = Framework.GetPlayerData()
return playerData.dead return playerData.dead
+134 -141
View File
@@ -4,19 +4,19 @@ if GetResourceState('es_extended') ~= 'started' then return end
Prints = Prints or Require("lib/utility/shared/prints.lua") Prints = Prints or Require("lib/utility/shared/prints.lua")
Callback = Callback or Require("lib/utility/shared/callbacks.lua") Callback = Callback or Require("lib/utility/shared/callbacks.lua")
ESX = exports["es_extended"]:getSharedObject() ESX = exports.es_extended:getSharedObject()
Framework = Framework or {} Framework = Framework or {}
local cachedItemList = nil local cachedItemList = nil
---This will return the name of the framework in use. --- @description This will return the name of the framework in use
---@return string --- @return string
Framework.GetFrameworkName = function() Framework.GetFrameworkName = function()
return 'es_extended' return 'es_extended'
end end
-- 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
Framework.ItemList = function() Framework.ItemList = function()
if cachedItemList then return cachedItemList end if cachedItemList then return cachedItemList end
local items = ESX.Items local items = ESX.Items
@@ -40,9 +40,9 @@ Framework.ItemList = function()
return cachedItemList return cachedItemList
end end
---This will return if the player is an admin in the framework. --- @description This will return if the player is an admin in the framework
---@param src any --- @param src any
---@return boolean --- @return boolean
Framework.GetIsFrameworkAdmin = function(src) Framework.GetIsFrameworkAdmin = function(src)
if not src then return false end if not src then return false end
local xPlayer = Framework.GetPlayer(src) local xPlayer = Framework.GetPlayer(src)
@@ -52,8 +52,8 @@ Framework.GetIsFrameworkAdmin = function(src)
return false return false
end end
---This will get the players birth date --- @description This will get the players birth date
---@return string|nil --- @return string|nil
Framework.GetPlayerDob = function(src) Framework.GetPlayerDob = function(src)
local xPlayer = Framework.GetPlayer(src) local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return end if not xPlayer then return end
@@ -61,43 +61,40 @@ Framework.GetPlayerDob = function(src)
return dob return dob
end end
--- Returns the player data of the specified source in the framework defualt format. --- @description Returns the player data of the specified source in the framework defualt format
---@param src any --- @param src any
---@return table | nil --- @return table | nil
Framework.GetPlayer = function(src) Framework.GetPlayer = function(src)
local xPlayer = ESX.GetPlayerFromId(src) local xPlayer = ESX.GetPlayerFromId(src)
if not xPlayer then return end if not xPlayer then return end
return xPlayer return xPlayer
end end
-- Framework.GetPlayerIdentifier(src) --- @description Returns the citizen ID of the player.
-- Returns the citizen ID of the player. --- @param src number
---@param src number --- @return string | nil returns the citizen ID of the player if it exists
---@return string | nil
Framework.GetPlayerIdentifier = function(src) Framework.GetPlayerIdentifier = function(src)
local xPlayer = Framework.GetPlayer(src) local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return end if not xPlayer then return end
return xPlayer.getIdentifier() return xPlayer.getIdentifier()
end end
---This will return the jobs registered in the framework in a table. --- @description This will return the jobs registered in the framework in a table.
---Format of the table is: --- @return table in the format "{name = jobName, label = jobLabel, grade = {name = gradeName, level = gradeLevel}}"
---{name = jobName, label = jobLabel, grade = {name = gradeName, level = gradeLevel}}
---@return table
Framework.GetFrameworkJobs = function() Framework.GetFrameworkJobs = function()
return ESX.GetJobs() return ESX.GetJobs()
end end
-- Framework.GetPlayerName(src)
-- Returns the first and last name of the player. --- @description This will return the first and last name of the player.
---@return string|nil, string|nil --- @return string|nil, string|nil returns the first and last name of the player
Framework.GetPlayerName = function(src) Framework.GetPlayerName = function(src)
local xPlayer = Framework.GetPlayer(src) local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return end if not xPlayer then return end
return xPlayer.variables.firstName, xPlayer.variables.lastName return xPlayer.variables.firstName, xPlayer.variables.lastName
end end
---This will return a table of all logged in players --- @description This will return a table of all logged in players
---@return table --- @return table
Framework.GetPlayers = function() Framework.GetPlayers = function()
local players = ESX.GetExtendedPlayers() local players = ESX.GetExtendedPlayers()
local playerList = {} local playerList = {}
@@ -107,12 +104,11 @@ Framework.GetPlayers = function()
return playerList return playerList
end end
---Returns a table of items matching the specified name and if passed metadata from the player's inventory. --- @description This will return a table of items matching the specified name and if passed metadata from the player's inventory
---returns {name = v.name, count = v.amount, metadata = v.info, slot = v.slot} --- @param src number
---@param src number --- @param item string
---@param item string --- @param _ table
---@param _ table --- @return table|nil returns {name = v.name, count = v.amount, metadata = v.info, slot = v.slot}
---@return table|nil
Framework.GetItem = function(src, item, _) Framework.GetItem = function(src, item, _)
local xPlayer = Framework.GetPlayer(src) local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return end if not xPlayer then return end
@@ -131,32 +127,29 @@ Framework.GetItem = function(src, item, _)
return repackedTable return repackedTable
end end
---This will return the count of the item in the players inventory, if not found will return 0. --- @param src number
---if metadata is passed it will find the matching items count (esx_core does not feature metadata items). --- @param item string
---@param src number --- @param _ table
---@param item string --- @return number returns the count of the item in the players inventory, if not found will return 0.
---@param _ table --- If metadata is passed it will find the matching items count (esx_core does not feature metadata items)
---@return number
Framework.GetItemCount = function(src, item, _) Framework.GetItemCount = function(src, item, _)
local xPlayer = Framework.GetPlayer(src) local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return end if not xPlayer then return end
return xPlayer.getInventoryItem(item).count return xPlayer.getInventoryItem(item).count
end end
---This will return a boolean if the player has the item. --- @description This will return true if the player has the item, false otherwise
---@param src number --- @param src number
---@param item string --- @param item string
---@return boolean --- @return boolean returns true if the player has the item, false otherwise.
Framework.HasItem = function(src, item) Framework.HasItem = function(src, item)
local getCount = Framework.GetItemCount(src, item, nil) local getCount = Framework.GetItemCount(src, item, nil)
return getCount > 0 return getCount > 0
end end
-- Framework.GetPlayerInventory(src) --- @description This will return the player's inventory as a table
-- Returns the entire inventory of the player as a table. --- @param src number
-- returns {name = v.name, count = v.amount, metadata = v.info, slot = v.slot} --- @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}
---@param src number
---@return table | nil
Framework.GetPlayerInventory = function(src) Framework.GetPlayerInventory = function(src)
local xPlayer = Framework.GetPlayer(src) local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return end if not xPlayer then return end
@@ -175,9 +168,11 @@ Framework.GetPlayerInventory = function(src)
return repackedTable return repackedTable
end end
-- Framework.SetMetadata(src, metadata, value) --- @description Adds the specified metadata key and number value to the player's data.
-- Adds the specified metadata key and number value to the player's data. --- @param src number
---@return boolean|nil --- @param metadata string
--- @param value any
--- @return boolean|nil returns true if the metadata was set successfully, otherwise it returns nil
Framework.SetPlayerMetadata = function(src, metadata, value) Framework.SetPlayerMetadata = function(src, metadata, value)
local xPlayer = Framework.GetPlayer(src) local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return end if not xPlayer then return end
@@ -186,39 +181,44 @@ Framework.SetPlayerMetadata = function(src, metadata, value)
end end
-- Framework.GetMetadata(src, metadata) -- Framework.GetMetadata(src, metadata)
-- 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 src number
---@param metadata string --- @param metadata string
---@return any|nil --- @return any|nil
Framework.GetPlayerMetadata = function(src, metadata) Framework.GetPlayerMetadata = function(src, metadata)
local xPlayer = Framework.GetPlayer(src) local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return end if not xPlayer then return end
return xPlayer.getMeta(metadata) or false return xPlayer.getMeta(metadata) or false
end end
-- defualt esx Available tables are --- @description This will return the specified status column of the player.
-- identifier, accounts, group, inventory, job, job_grade, loadout, --- @param src number
-- metadata, position, firstname, lastname, dateofbirth, sex, height, --- @param column string
-- skin, status, is_dead, id, disabled, last_property, created_at, last_seen, --- @return string|nil
-- phone_number, pincode
Framework.GetStatus = function(src, column) Framework.GetStatus = function(src, column)
--[[
defualt esx Available tables are:
identifier, accounts, group, inventory, job, job_grade, loadout, metadata, position,
firstname, lastname, dateofbirth, sex, height, skin, status, is_dead, id, disabled,
last_property, created_at, last_seen, phone_number, pincode
]]
local xPlayer = Framework.GetPlayer(src) local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return end if not xPlayer then return end
return xPlayer.get(column) or nil return xPlayer.get(column) or nil
end end
---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 --- @param src number
---@return boolean|nil --- @return boolean|nil
Framework.GetIsPlayerDead = function(src) Framework.GetIsPlayerDead = function(src)
local xPlayer = Framework.GetPlayer(src) local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return end if not xPlayer then return end
return xPlayer.get("is_dead") or false return xPlayer.get("is_dead") or false
end end
---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 --- @param src number
---@return boolean --- @return boolean
Framework.RevivePlayer = function(src) Framework.RevivePlayer = function(src)
src = tonumber(src) src = tonumber(src)
if not src then return false end if not src then return false end
@@ -226,11 +226,10 @@ Framework.RevivePlayer = function(src)
return true return true
end end
-- Framework.AddThirst(src, value) --- @description Adds the specified value from the player's thirst level
-- Adds the specified value from the player's thirst level. --- @param src number
---@param src number --- @param value number
---@param value number --- @return number | nil
---@return number | nil
Framework.AddThirst = function(src, value) Framework.AddThirst = function(src, value)
local clampIT = Math.Clamp(value, 0, 200000) local clampIT = Math.Clamp(value, 0, 200000)
local levelForEsx = clampIT * 2000 local levelForEsx = clampIT * 2000
@@ -238,11 +237,10 @@ Framework.AddThirst = function(src, value)
return levelForEsx return levelForEsx
end end
-- Framework.AddHunger(src, value) --- @description Adds the specified value from the player's hunger level
-- Adds the specified value from the player's hunger level. --- @param src number
---@param src number --- @param value number
---@param value number --- @return number | nil
---@return number | nil
Framework.AddHunger = function(src, value) Framework.AddHunger = function(src, value)
local clampIT = Math.Clamp(value, 0, 200000) local clampIT = Math.Clamp(value, 0, 200000)
local levelForEsx = clampIT * 2000 local levelForEsx = clampIT * 2000
@@ -250,36 +248,34 @@ Framework.AddHunger = function(src, value)
return levelForEsx return levelForEsx
end end
---This will get the hunger of a player --- @description This will get the hunger of a player
---@param src number --- @param src number
---@return number | nil --- @return number | nil
Framework.GetHunger = function(src) Framework.GetHunger = function(src)
local status = Framework.GetStatus(src, "status") local status = Framework.GetStatus(src, "status")
if not status then return 0 end if not status then return 0 end
return status.hunger return status.hunger
end end
---This will get the thirst of a player --- @description This will get the thirst of a player
---@param src any --- @param src any
---@return number | nil --- @return number | nil
Framework.GetThirst = function(src) Framework.GetThirst = function(src)
local status = Framework.GetStatus(src, "status") local status = Framework.GetStatus(src, "status")
if not status then return 0 end if not status then return 0 end
return status.thirst return status.thirst
end end
-- Framework.GetPlayerPhone(src) --- @description This will get the phone number of a player
-- Returns the phone number of the player. --- @param src number
---@param src number --- @return string | nil return the phone number of the player
---@return string | nil
Framework.GetPlayerPhone = function(src) Framework.GetPlayerPhone = function(src)
local xPlayer = Framework.GetPlayer(src) local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return end if not xPlayer then return end
return xPlayer.get("phone_number") return xPlayer.get("phone_number")
end end
---@deprecated This will return the job name, label, grade name, and grade level of the player.
---Depricated: Returns the job name, label, grade name, and grade level of the player.
---@param src number ---@param src number
---@return string | nil ---@return string | nil
---@return string | nil ---@return string | nil
@@ -292,9 +288,10 @@ Framework.GetPlayerJob = function(src)
return job.name, job.label, job.grade_label, job.grade return job.name, job.label, job.grade_label, job.grade
end end
---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,
---@param src number --- boss status, and duty status in a table
---@return table | nil --- @param src number
--- @return table | nil
Framework.GetPlayerJobData = function(src) Framework.GetPlayerJobData = function(src)
local xPlayer = Framework.GetPlayer(src) local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return end if not xPlayer then return end
@@ -311,9 +308,9 @@ Framework.GetPlayerJobData = function(src)
} }
end end
---Returns the players duty status. --- @description This will return the players duty status, true if on duty false otherwise
---@param src number --- @param src number
---@return boolean --- @return boolean return the players duty status
Framework.GetPlayerDuty = function(src) Framework.GetPlayerDuty = function(src)
local xPlayer = Framework.GetPlayer(src) local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return false end if not xPlayer then return false end
@@ -322,10 +319,10 @@ Framework.GetPlayerDuty = function(src)
return true return true
end end
---This will toggle a players duty status --- @description This will toggle a players duty status
---@param src number --- @param src number
---@param status boolean --- @param status boolean
---@return boolean --- @return boolean
Framework.SetPlayerDuty = function(src, status) Framework.SetPlayerDuty = function(src, status)
local xPlayer = Framework.GetPlayer(src) local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return false end if not xPlayer then return false end
@@ -335,18 +332,18 @@ Framework.SetPlayerDuty = function(src, status)
return true return true
end end
---This will get a table of player sources that have the specified job name. --- @description This will get a table of player sources that have the specified job name
---@param job string --- @param job string
---@return table --- @return table
Framework.GetPlayersByJob = function(job) Framework.GetPlayersByJob = function(job)
return Framework.GetPlayerSourcesByJob(job) or {} return Framework.GetPlayerSourcesByJob(job) or {}
end end
-- Sets the player's job to the specified name and grade. --- @description This will set the player's job to the specified name and grade
---@param src number --- @param src number
---@param name string --- @param name string
---@param grade string --- @param grade string
---@return nil --- @return nil
Framework.SetPlayerJob = function(src, name, grade) Framework.SetPlayerJob = function(src, name, grade)
local xPlayer = Framework.GetPlayer(src) local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return end if not xPlayer then return end
@@ -358,11 +355,11 @@ Framework.SetPlayerJob = function(src, name, grade)
return true return true
end end
---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 src number
---@param _type string --- @param _type string
---@param amount number --- @param amount number
---@return boolean | nil --- @return boolean | nil
Framework.AddAccountBalance = function(src, _type, amount) Framework.AddAccountBalance = function(src, _type, amount)
local xPlayer = Framework.GetPlayer(src) local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return end if not xPlayer then return end
@@ -371,11 +368,11 @@ Framework.AddAccountBalance = function(src, _type, amount)
return true return true
end end
---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 src number
---@param _type string --- @param _type string
---@param amount number --- @param amount number
---@return boolean | nil --- @return boolean | nil
Framework.RemoveAccountBalance = function(src, _type, amount) Framework.RemoveAccountBalance = function(src, _type, amount)
local xPlayer = Framework.GetPlayer(src) local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return end if not xPlayer then return end
@@ -384,10 +381,10 @@ Framework.RemoveAccountBalance = function(src, _type, amount)
return true return true
end end
---This will remove money based on the type of account (money/bank) --- @description This will get the account balance based on the type of account (money/bank)
---@param src number --- @param src number
---@param _type string --- @param _type string
---@return string | nil --- @return string | nil
Framework.GetAccountBalance = function(src, _type) Framework.GetAccountBalance = function(src, _type)
local xPlayer = Framework.GetPlayer(src) local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return end if not xPlayer then return end
@@ -395,14 +392,13 @@ Framework.GetAccountBalance = function(src, _type)
return xPlayer.getAccount(_type).money return xPlayer.getAccount(_type).money
end end
-- Framework.AddItem(src, item, amount, slot, metadata) --- @description Adds the specified item to the player's inventory
-- Adds the specified item to the player's inventory. --- @param src number
---@param src number --- @param item string
---@param item string --- @param amount number
---@param amount number --- @param slot number
---@param slot number --- @param metadata table
---@param metadata table --- @return boolean | nil
---@return boolean | nil
Framework.AddItem = function(src, item, amount, slot, metadata) Framework.AddItem = function(src, item, amount, slot, metadata)
local xPlayer = Framework.GetPlayer(src) local xPlayer = Framework.GetPlayer(src)
if not xPlayer then return end if not xPlayer then return end
@@ -410,13 +406,12 @@ Framework.AddItem = function(src, item, amount, slot, metadata)
return true return true
end end
-- Framework.RemoveItem(src, item, amount, slot, metadata) --- @description Removes the specified item from the player's inventory
-- Removes the specified item from the player's inventory. --- @param src number
---@param src number --- @param item string
---@param item string --- @param amount number
---@param amount number --- @param slot number
---@param slot number --- @param metadata table
---@param metadata table
---@return boolean | nil ---@return boolean | nil
Framework.RemoveItem = function(src, item, amount, slot, metadata) Framework.RemoveItem = function(src, item, amount, slot, metadata)
local xPlayer = Framework.GetPlayer(src) local xPlayer = Framework.GetPlayer(src)
@@ -425,9 +420,9 @@ Framework.RemoveItem = function(src, item, amount, slot, metadata)
return true return true
end end
---This will get all owned vehicles for the player --- @description This will get all owned vehicles for the player
---@param src number --- @param src number
---@return table --- @return table
Framework.GetOwnedVehicles = function(src) Framework.GetOwnedVehicles = function(src)
local citizenId = Framework.GetPlayerIdentifier(src) local citizenId = Framework.GetPlayerIdentifier(src)
local result = MySQL.Sync.fetchAll("SELECT vehicle, plate FROM owned_vehicles WHERE owner = '" .. citizenId .. "'") local result = MySQL.Sync.fetchAll("SELECT vehicle, plate FROM owned_vehicles WHERE owner = '" .. citizenId .. "'")
@@ -441,11 +436,9 @@ Framework.GetOwnedVehicles = function(src)
return vehicles return vehicles
end end
--- @description Registers a usable item with a callback function
-- Framework.RegisterUsableItem(item, cb) --- @param itemName string
-- Registers a usable item with a callback function. --- @param cb function
---@param itemName string
---@param cb function
Framework.RegisterUsableItem = function(itemName, cb) Framework.RegisterUsableItem = function(itemName, cb)
local func = function(src, item, itemData) local func = function(src, item, itemData)
itemData = itemData or item itemData = itemData or item