Merge branch 'dev' of https://github.com/The-Order-Of-The-Sacred-Framework/community_bridge into dev
This commit is contained in:
commit
7610cadf04
9 files changed
+262
-83
No files matched your search
@@ -5,11 +5,14 @@ ESX = exports["es_extended"]:getSharedObject()
|
|||||||
|
|
||||||
Framework = Framework or {}
|
Framework = Framework or {}
|
||||||
|
|
||||||
|
---This will get the name of the framework being used (if a supported framework).
|
||||||
|
---@return string
|
||||||
Framework.GetFrameworkName = function()
|
Framework.GetFrameworkName = function()
|
||||||
return 'es_extended'
|
return 'es_extended'
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will return a table of the players data, this is an internal table and should not be used.
|
---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.
|
||||||
---@return table
|
---@return table
|
||||||
Framework.GetPlayerData = function()
|
Framework.GetPlayerData = function()
|
||||||
return ESX.GetPlayerData()
|
return ESX.GetPlayerData()
|
||||||
@@ -32,13 +35,13 @@ Framework.GetPlayerDob = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
---This will return the players metadata for the specified metadata key.
|
---This will return the players metadata for the specified metadata key.
|
||||||
---@param metadata string
|
---@param metadata table | string
|
||||||
---@return table | nil
|
---@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 prompt the user with a notification message
|
---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
|
||||||
@@ -61,14 +64,14 @@ Framework.HideHelpText = function()
|
|||||||
return exports['esx_textui']:HideUI()
|
return exports['esx_textui']:HideUI()
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will return the players identifier
|
---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 return the players first name, and the last name
|
---This will get the players name (first and last).
|
||||||
---@return string
|
---@return string
|
||||||
---@return string
|
---@return string
|
||||||
Framework.GetPlayerName = function()
|
Framework.GetPlayerName = function()
|
||||||
@@ -103,7 +106,7 @@ Framework.GetPlayerJobData = function()
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will return a boolean if the player has the item in their inventory
|
---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)
|
||||||
@@ -111,6 +114,15 @@ Framework.HasItem = function(item)
|
|||||||
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.
|
||||||
|
---@param item string
|
||||||
|
---@return number
|
||||||
|
Framework.GetItemCount = function(item)
|
||||||
|
local inventory = Framework.GetPlayerInventory()
|
||||||
|
if not inventory then return 0 end
|
||||||
|
return inventory[item].count or 0
|
||||||
|
end
|
||||||
|
|
||||||
---This will return a table of the players inventory
|
---This will return a table of the players inventory
|
||||||
---@return table
|
---@return table
|
||||||
Framework.GetPlayerInventory = function()
|
Framework.GetPlayerInventory = function()
|
||||||
@@ -118,16 +130,7 @@ Framework.GetPlayerInventory = function()
|
|||||||
return playerData.inventory
|
return playerData.inventory
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will return a number of the item in the players inventory
|
---This will get a players dead status.
|
||||||
---@param item string
|
|
||||||
---@return number
|
|
||||||
Framework.GetItemCount = function(item)
|
|
||||||
local inventory = Framework.GetPlayerInventory()
|
|
||||||
if not inventory then return 0 end
|
|
||||||
return inventory[item].count or 0
|
|
||||||
end
|
|
||||||
|
|
||||||
---This will return a boolean if the player is dead
|
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Framework.GetIsPlayerDead = function()
|
Framework.GetIsPlayerDead = function()
|
||||||
local playerData = Framework.GetPlayerData()
|
local playerData = Framework.GetPlayerData()
|
||||||
|
|||||||
@@ -7,10 +7,14 @@ ESX = exports["es_extended"]:getSharedObject()
|
|||||||
|
|
||||||
Framework = Framework or {}
|
Framework = Framework or {}
|
||||||
|
|
||||||
|
---This will return the name of the framework in use.
|
||||||
|
---@return string
|
||||||
Framework.GetFrameworkName = function()
|
Framework.GetFrameworkName = function()
|
||||||
return 'es_extended'
|
return 'es_extended'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---This will get the players birth date
|
||||||
|
---@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
|
||||||
@@ -18,9 +22,7 @@ Framework.GetPlayerDob = function(src)
|
|||||||
return dob
|
return dob
|
||||||
end
|
end
|
||||||
|
|
||||||
--- This will return a table of the players data
|
--- Returns the player data of the specified source in the framework defualt format.
|
||||||
---
|
|
||||||
--- This table is in the framework format and not converted to any standard.
|
|
||||||
---@param src any
|
---@param src any
|
||||||
---@return table | nil
|
---@return table | nil
|
||||||
Framework.GetPlayer = function(src)
|
Framework.GetPlayer = function(src)
|
||||||
@@ -31,18 +33,24 @@ end
|
|||||||
|
|
||||||
-- Framework.GetPlayerIdentifier(src)
|
-- Framework.GetPlayerIdentifier(src)
|
||||||
-- Returns the citizen ID of the player.
|
-- Returns the citizen ID of the player.
|
||||||
|
---@param src number
|
||||||
|
---@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.
|
||||||
|
---Format of the table is:
|
||||||
|
---{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)
|
-- Framework.GetPlayerName(src)
|
||||||
-- Returns the first and last name of the player.
|
-- Returns the first and last name of the player.
|
||||||
|
---@return string|nil, string|nil
|
||||||
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
|
||||||
@@ -60,9 +68,12 @@ Framework.GetPlayers = function()
|
|||||||
return playerList
|
return playerList
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Framework.GetItem(src, item, metadata)
|
---Returns a table of items matching the specified name and if passed metadata from the player's inventory.
|
||||||
-- Returns 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}
|
||||||
-- returns {name = v.name, count = v.amount, metadata = v.info, slot = v.slot}
|
---@param src number
|
||||||
|
---@param item string
|
||||||
|
---@param _ table
|
||||||
|
---@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
|
||||||
@@ -81,15 +92,19 @@ Framework.GetItem = function(src, item, _)
|
|||||||
return repackedTable
|
return repackedTable
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Framework.GetItemCount(src, item, _)
|
---This will return the count of the item in the players inventory, if not found will return 0.
|
||||||
-- Returns the count of items matching the specified name and if passed metadata from the player's inventory.
|
---if metadata is passed it will find the matching items count (esx_core does not feature metadata items).
|
||||||
|
---@param src number
|
||||||
|
---@param item string
|
||||||
|
---@param _ table
|
||||||
|
---@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
|
||||||
|
|
||||||
---comment
|
---This will return a boolean if the player has the item.
|
||||||
---@param src number
|
---@param src number
|
||||||
---@param item string
|
---@param item string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
@@ -100,7 +115,9 @@ end
|
|||||||
|
|
||||||
-- Framework.GetPlayerInventory(src)
|
-- Framework.GetPlayerInventory(src)
|
||||||
-- Returns the entire inventory of the player as a table.
|
-- Returns the entire inventory of the player as a table.
|
||||||
-- returns {name = v.name, count = v.amount, _, _}
|
-- returns {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
|
||||||
@@ -121,6 +138,7 @@ end
|
|||||||
|
|
||||||
-- Framework.SetMetadata(src, metadata, value)
|
-- Framework.SetMetadata(src, metadata, value)
|
||||||
-- 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.
|
||||||
|
---@return boolean|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
|
||||||
@@ -129,7 +147,10 @@ Framework.SetPlayerMetadata = function(src, metadata, value)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Framework.GetMetadata(src, metadata)
|
-- Framework.GetMetadata(src, metadata)
|
||||||
-- Gets the specified metadata key and value to the player's data.
|
-- Gets the specified metadata key to the player's data.
|
||||||
|
---@param src number
|
||||||
|
---@param metadata string
|
||||||
|
---@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
|
||||||
@@ -147,12 +168,18 @@ Framework.GetStatus = function(src, column)
|
|||||||
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.
|
||||||
|
---@param src number
|
||||||
|
---@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.
|
||||||
|
---@param src number
|
||||||
|
---@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
|
||||||
@@ -162,6 +189,9 @@ end
|
|||||||
|
|
||||||
-- Framework.AddThirst(src, value)
|
-- Framework.AddThirst(src, value)
|
||||||
-- Adds the specified value from the player's thirst level.
|
-- Adds the specified value from the player's thirst level.
|
||||||
|
---@param src number
|
||||||
|
---@param value number
|
||||||
|
---@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
|
||||||
@@ -171,6 +201,9 @@ end
|
|||||||
|
|
||||||
-- Framework.AddHunger(src, value)
|
-- Framework.AddHunger(src, value)
|
||||||
-- Adds the specified value from the player's hunger level.
|
-- Adds the specified value from the player's hunger level.
|
||||||
|
---@param src number
|
||||||
|
---@param value number
|
||||||
|
---@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
|
||||||
@@ -178,12 +211,18 @@ Framework.AddHunger = function(src, value)
|
|||||||
return levelForEsx
|
return levelForEsx
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---This will get the hunger of a player
|
||||||
|
---@param src number
|
||||||
|
---@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
|
||||||
|
---@param src any
|
||||||
|
---@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
|
||||||
@@ -192,6 +231,8 @@ end
|
|||||||
|
|
||||||
-- Framework.GetPlayerPhone(src)
|
-- Framework.GetPlayerPhone(src)
|
||||||
-- Returns the phone number of the player.
|
-- Returns the phone number of the player.
|
||||||
|
---@param src number
|
||||||
|
---@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
|
||||||
@@ -242,9 +283,9 @@ Framework.GetPlayerDuty = function(src)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
---Sets the players duty status.
|
---This will toggle a players duty status
|
||||||
---@param src number
|
---@param src number
|
||||||
---@param dutystatus boolean
|
---@param status boolean
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Framework.SetPlayerDuty = function(src, dutystatus)
|
Framework.SetPlayerDuty = function(src, dutystatus)
|
||||||
local xPlayer = Framework.GetPlayer(src)
|
local xPlayer = Framework.GetPlayer(src)
|
||||||
@@ -254,22 +295,26 @@ Framework.SetPlayerDuty = function(src, dutystatus)
|
|||||||
return xPlayer.setJob(job.name, job.grade, dutystatus)
|
return xPlayer.setJob(job.name, job.grade, dutystatus)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Framework.GetPlayersByJob(jobname)
|
---This will get a table of player sources that have the specified job name.
|
||||||
-- returns a table of player sources that have the specified job name.
|
---@param job any
|
||||||
|
---@return table
|
||||||
Framework.GetPlayersByJob = function(job)
|
Framework.GetPlayersByJob = function(job)
|
||||||
local players = GetPlayers()
|
local players = GetPlayers()
|
||||||
local playerList = {}
|
local playerList = {}
|
||||||
for _, src in pairs(players) do
|
for _, src in pairs(players) do
|
||||||
local xPlayer = Framework.GetPlayer(src)
|
local xPlayer = Framework.GetPlayer(src)
|
||||||
if xPlayer.getJob().name == job then
|
if xPlayer and xPlayer.getJob().name == job then
|
||||||
table.insert(playerList, src)
|
table.insert(playerList, src)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return playerList
|
return playerList
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Framework.SetPlayerJob(src, name, grade)
|
|
||||||
-- Sets the player's job to the specified name and grade.
|
-- 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)
|
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
|
||||||
@@ -280,8 +325,11 @@ Framework.SetPlayerJob = function(src, name, grade)
|
|||||||
return xPlayer.setJob(name, grade, true)
|
return xPlayer.setJob(name, grade, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Framework.AddAccountBalance(src, _type, amount)
|
---This will add money based on the type of account (money/bank)
|
||||||
-- Adds the specified amount to the player's account balance of the specified type.
|
---@param src number
|
||||||
|
---@param _type string
|
||||||
|
---@param amount number
|
||||||
|
---@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
|
||||||
@@ -289,8 +337,11 @@ Framework.AddAccountBalance = function(src, _type, amount)
|
|||||||
return xPlayer.addAccountMoney(_type, amount)
|
return xPlayer.addAccountMoney(_type, amount)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Framework.RemoveAccountBalance(src, _type, amount)
|
---This will remove money based on the type of account (money/bank)
|
||||||
-- Removes the specified amount from the player's account balance of the specified type.
|
---@param src number
|
||||||
|
---@param _type string
|
||||||
|
---@param amount number
|
||||||
|
---@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
|
||||||
@@ -299,8 +350,10 @@ Framework.RemoveAccountBalance = function(src, _type, amount)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Framework.GetAccountBalance(src, _type)
|
---This will remove money based on the type of account (money/bank)
|
||||||
-- Returns the player's account balance of the specified type.
|
---@param src number
|
||||||
|
---@param _type string
|
||||||
|
---@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
|
||||||
@@ -308,22 +361,37 @@ Framework.GetAccountBalance = function(src, _type)
|
|||||||
return xPlayer.getAccount(_type).money
|
return xPlayer.getAccount(_type).money
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Framework.AddItem(src, item, amount, _, _)
|
-- Framework.AddItem(src, item, amount, slot, metadata)
|
||||||
-- Adds the specified item to the player's inventory.
|
-- 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)
|
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
|
||||||
return xPlayer.addInventoryItem(item, amount)
|
return xPlayer.addInventoryItem(item, amount)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Framework.RemoveItem(src, item, amount, _, _)
|
-- Framework.RemoveItem(src, item, amount, slot, metadata)
|
||||||
-- Removes the specified item from the player's inventory.
|
-- Removes the specified item from the player's inventory.
|
||||||
|
---@param src number
|
||||||
|
---@param item string
|
||||||
|
---@param amount number
|
||||||
|
---@param slot number
|
||||||
|
---@param metadata table
|
||||||
|
---@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)
|
||||||
if not xPlayer then return end
|
if not xPlayer then return end
|
||||||
return xPlayer.removeInventoryItem(item, amount)
|
return xPlayer.removeInventoryItem(item, amount)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---This will get all owned vehicles for the player
|
||||||
|
---@param src number
|
||||||
|
---@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 .. "'")
|
||||||
@@ -337,8 +405,11 @@ Framework.GetOwnedVehicles = function(src)
|
|||||||
return vehicles
|
return vehicles
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Framework.RegisterUsableItem(item, cb)
|
-- Framework.RegisterUsableItem(item, cb)
|
||||||
-- Registers a usable item with a callback function.
|
-- Registers a usable item with a callback 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
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ Framework.GetFrameworkName = function()
|
|||||||
return 'qb-core'
|
return 'qb-core'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---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.
|
||||||
|
---@return table
|
||||||
Framework.GetPlayerData = function()
|
Framework.GetPlayerData = function()
|
||||||
return QBCore.Functions.GetPlayerData()
|
return QBCore.Functions.GetPlayerData()
|
||||||
end
|
end
|
||||||
@@ -47,6 +50,11 @@ Framework.GetPlayerMetaData = function(metadata)
|
|||||||
return Framework.GetPlayerData().metadata[metadata]
|
return Framework.GetPlayerData().metadata[metadata]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---This will send a notification to the player.
|
||||||
|
---@param message string
|
||||||
|
---@param type string
|
||||||
|
---@param time number
|
||||||
|
---@return nil
|
||||||
Framework.Notify = function(message, type, time)
|
Framework.Notify = function(message, type, time)
|
||||||
TriggerEvent('QBCore:Notify', message, 'primary', time)
|
TriggerEvent('QBCore:Notify', message, 'primary', time)
|
||||||
end
|
end
|
||||||
@@ -65,6 +73,9 @@ Framework.HideHelpText = function()
|
|||||||
return exports['qb-core']:HideText()
|
return exports['qb-core']:HideText()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---This will return the item data for the specified item.
|
||||||
|
---@param item string
|
||||||
|
---@return table
|
||||||
Framework.GetItemInfo = function(item)
|
Framework.GetItemInfo = function(item)
|
||||||
local itemData = QBCore.Shared.Items[item]
|
local itemData = QBCore.Shared.Items[item]
|
||||||
if not itemData then return {} end
|
if not itemData then return {} end
|
||||||
@@ -119,11 +130,14 @@ Framework.GetPlayerJobData = function()
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---This will return if the player has the specified item in their inventory.
|
||||||
|
---@param item string
|
||||||
|
---@return boolean
|
||||||
Framework.HasItem = function(item)
|
Framework.HasItem = function(item)
|
||||||
return QBCore.Functions.HasItem(item)
|
return QBCore.Functions.HasItem(item)
|
||||||
end
|
end
|
||||||
|
|
||||||
---comment
|
---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)
|
||||||
@@ -137,6 +151,8 @@ Framework.GetItemCount = function(item)
|
|||||||
return count
|
return count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---This will return the players inventory as a table in the ox_inventory style flormat.
|
||||||
|
---@return table
|
||||||
Framework.GetPlayerInventory = function()
|
Framework.GetPlayerInventory = function()
|
||||||
local items = {}
|
local items = {}
|
||||||
local frameworkInv = Framework.GetPlayerData().items
|
local frameworkInv = Framework.GetPlayerData().items
|
||||||
|
|||||||
@@ -8,12 +8,16 @@ QBCore = exports['qb-core']:GetCoreObject()
|
|||||||
|
|
||||||
Framework.Shared = QBCore.Shared
|
Framework.Shared = QBCore.Shared
|
||||||
|
|
||||||
|
---This will return the name of the framework in use.
|
||||||
|
---@return string
|
||||||
Framework.GetFrameworkName = function()
|
Framework.GetFrameworkName = function()
|
||||||
return 'qb-core'
|
return 'qb-core'
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Framework.GetPlayerIdentifier(src)
|
-- Framework.GetPlayerIdentifier(src)
|
||||||
-- Returns the citizen ID of the player.
|
-- Returns the citizen ID of the player.
|
||||||
|
---@param src number
|
||||||
|
---@return string | nil
|
||||||
Framework.GetPlayerIdentifier = function(src)
|
Framework.GetPlayerIdentifier = function(src)
|
||||||
local player = Framework.GetPlayer(src)
|
local player = Framework.GetPlayer(src)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
@@ -21,7 +25,7 @@ Framework.GetPlayerIdentifier = function(src)
|
|||||||
return playerData.citizenid
|
return playerData.citizenid
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns the player data of the specified source.
|
--- 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)
|
||||||
@@ -30,6 +34,10 @@ Framework.GetPlayer = function(src)
|
|||||||
return player
|
return player
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---This will return the jobs registered in the framework in a table.
|
||||||
|
---Format of the table is:
|
||||||
|
---{name = jobName, label = jobLabel, grade = {name = gradeName, level = gradeLevel}}
|
||||||
|
---@return table
|
||||||
Framework.GetFrameworkJobs = function()
|
Framework.GetFrameworkJobs = function()
|
||||||
local jobs = {}
|
local jobs = {}
|
||||||
for k, v in pairs(QBCore.Shared.Jobs) do
|
for k, v in pairs(QBCore.Shared.Jobs) do
|
||||||
@@ -44,7 +52,7 @@ end
|
|||||||
|
|
||||||
-- Framework.GetPlayerName(src)
|
-- Framework.GetPlayerName(src)
|
||||||
-- Returns the first and last name of the player.
|
-- Returns the first and last name of the player.
|
||||||
---@return string, string
|
---@return string|nil, string|nil
|
||||||
Framework.GetPlayerName = function(src)
|
Framework.GetPlayerName = function(src)
|
||||||
local player = Framework.GetPlayer(src)
|
local player = Framework.GetPlayer(src)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
@@ -52,8 +60,9 @@ Framework.GetPlayerName = function(src)
|
|||||||
return playerData.charinfo.firstname, playerData.charinfo.lastname
|
return playerData.charinfo.firstname, playerData.charinfo.lastname
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will get the players birth date
|
---Returns the player date of birth.
|
||||||
---@return string
|
---@param src number
|
||||||
|
---@return string|nil
|
||||||
Framework.GetPlayerDob = function(src)
|
Framework.GetPlayerDob = function(src)
|
||||||
local player = Framework.GetPlayer(src)
|
local player = Framework.GetPlayer(src)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
@@ -61,9 +70,12 @@ Framework.GetPlayerDob = function(src)
|
|||||||
return playerData.charinfo.birthdate
|
return playerData.charinfo.birthdate
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Framework.GetItem(src, item, metadata)
|
---Returns a table of items matching the specified name and if passed metadata from the player's inventory.
|
||||||
-- Returns 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}
|
||||||
-- returns {name = v.name, count = v.amount, metadata = v.info, slot = v.slot}
|
---@param src number
|
||||||
|
---@param item string
|
||||||
|
---@param metadata table
|
||||||
|
---@return table|nil
|
||||||
Framework.GetItem = function(src, item, metadata)
|
Framework.GetItem = function(src, item, metadata)
|
||||||
local player = Framework.GetPlayer(src)
|
local player = Framework.GetPlayer(src)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
@@ -109,7 +121,7 @@ end
|
|||||||
---@return number
|
---@return number
|
||||||
Framework.GetItemCount = function(src, item, metadata)
|
Framework.GetItemCount = function(src, item, metadata)
|
||||||
local player = Framework.GetPlayer(src)
|
local player = Framework.GetPlayer(src)
|
||||||
if not player then return end
|
if not player then return 0 end
|
||||||
local playerData = player.PlayerData
|
local playerData = player.PlayerData
|
||||||
local playerInventory = playerData.items
|
local playerInventory = playerData.items
|
||||||
local count = 0
|
local count = 0
|
||||||
@@ -133,6 +145,8 @@ end
|
|||||||
-- Framework.GetPlayerInventory(src)
|
-- Framework.GetPlayerInventory(src)
|
||||||
-- Returns the entire inventory of the player as a table.
|
-- Returns the entire inventory of the player as a table.
|
||||||
-- returns {name = v.name, count = v.amount, metadata = v.info, slot = v.slot}
|
-- returns {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 player = Framework.GetPlayer(src)
|
local player = Framework.GetPlayer(src)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
@@ -161,6 +175,11 @@ Framework.GetPlayers = function()
|
|||||||
return playerList
|
return playerList
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---This will return the item data for the specified slot.
|
||||||
|
---Format {name, label, weight, count, metadata, slot, stack, description}
|
||||||
|
---@param src number
|
||||||
|
---@param slot number
|
||||||
|
---@return table|nil
|
||||||
Framework.GetItemBySlot = function(src, slot)
|
Framework.GetItemBySlot = function(src, slot)
|
||||||
local player = Framework.GetPlayer(src)
|
local player = Framework.GetPlayer(src)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
@@ -186,7 +205,7 @@ end
|
|||||||
|
|
||||||
-- Framework.SetMetadata(src, metadata, value)
|
-- Framework.SetMetadata(src, metadata, value)
|
||||||
-- 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.
|
||||||
---@return boolean | nil
|
---@return boolean|nil
|
||||||
Framework.SetPlayerMetadata = function(src, metadata, value)
|
Framework.SetPlayerMetadata = function(src, metadata, value)
|
||||||
local player = Framework.GetPlayer(src)
|
local player = Framework.GetPlayer(src)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
@@ -196,6 +215,9 @@ end
|
|||||||
|
|
||||||
-- Framework.GetMetadata(src, metadata)
|
-- Framework.GetMetadata(src, metadata)
|
||||||
-- Gets the specified metadata key to the player's data.
|
-- Gets the specified metadata key to the player's data.
|
||||||
|
---@param src number
|
||||||
|
---@param metadata string
|
||||||
|
---@return any|nil
|
||||||
Framework.GetPlayerMetadata = function(src, metadata)
|
Framework.GetPlayerMetadata = function(src, metadata)
|
||||||
local player = Framework.GetPlayer(src)
|
local player = Framework.GetPlayer(src)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
@@ -205,6 +227,8 @@ end
|
|||||||
|
|
||||||
-- Framework.AddStress(src, value)
|
-- Framework.AddStress(src, value)
|
||||||
-- Adds the specified value to the player's stress level and updates the client HUD.
|
-- Adds the specified value to the player's stress level and updates the client HUD.
|
||||||
|
---@param src number
|
||||||
|
---@param value number
|
||||||
---@return number | nil
|
---@return number | nil
|
||||||
Framework.AddStress = function(src, value)
|
Framework.AddStress = function(src, value)
|
||||||
local player = Framework.GetPlayer(src)
|
local player = Framework.GetPlayer(src)
|
||||||
@@ -218,6 +242,8 @@ end
|
|||||||
|
|
||||||
-- Framework.RemoveStress(src, value)
|
-- Framework.RemoveStress(src, value)
|
||||||
-- Removes the specified value from the player's stress level and updates the client HUD.
|
-- Removes the specified value from the player's stress level and updates the client HUD.
|
||||||
|
---@param src number
|
||||||
|
---@param value number
|
||||||
---@return number | nil
|
---@return number | nil
|
||||||
Framework.RemoveStress = function(src, value)
|
Framework.RemoveStress = function(src, value)
|
||||||
local player = Framework.GetPlayer(src)
|
local player = Framework.GetPlayer(src)
|
||||||
@@ -231,6 +257,8 @@ end
|
|||||||
|
|
||||||
-- Framework.AddHunger(src, value)
|
-- Framework.AddHunger(src, value)
|
||||||
-- Adds the specified value from the player's hunger level.
|
-- Adds the specified value from the player's hunger level.
|
||||||
|
---@param src number
|
||||||
|
---@param value number
|
||||||
---@return number | nil
|
---@return number | nil
|
||||||
Framework.AddHunger = function(src, value)
|
Framework.AddHunger = function(src, value)
|
||||||
local player = Framework.GetPlayer(src)
|
local player = Framework.GetPlayer(src)
|
||||||
@@ -240,12 +268,13 @@ Framework.AddHunger = function(src, value)
|
|||||||
player.Functions.SetMetaData('hunger', Math.Clamp(newHunger, 0, 100))
|
player.Functions.SetMetaData('hunger', Math.Clamp(newHunger, 0, 100))
|
||||||
TriggerClientEvent('hud:client:UpdateNeeds', src, newHunger, playerData.metadata.thirst)
|
TriggerClientEvent('hud:client:UpdateNeeds', src, newHunger, playerData.metadata.thirst)
|
||||||
--TriggerClientEvent('hud:client:UpdateStress', src, newStress)
|
--TriggerClientEvent('hud:client:UpdateStress', src, newStress)
|
||||||
|
|
||||||
return newHunger
|
return newHunger
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Framework.AddThirst(src, value)
|
-- Framework.AddThirst(src, value)
|
||||||
-- Adds the specified value from the player's thirst level.
|
-- Adds the specified value from the player's thirst level.
|
||||||
|
---@param src number
|
||||||
|
---@param value number
|
||||||
---@return number | nil
|
---@return number | nil
|
||||||
Framework.AddThirst = function(src, value)
|
Framework.AddThirst = function(src, value)
|
||||||
local player = Framework.GetPlayer(src)
|
local player = Framework.GetPlayer(src)
|
||||||
@@ -259,7 +288,7 @@ Framework.AddThirst = function(src, value)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---This will get the hunger of a player
|
---This will get the hunger of a player
|
||||||
---@param src any
|
---@param src number
|
||||||
---@return number | nil
|
---@return number | nil
|
||||||
Framework.GetHunger = function(src)
|
Framework.GetHunger = function(src)
|
||||||
local player = Framework.GetPlayer(src)
|
local player = Framework.GetPlayer(src)
|
||||||
@@ -269,6 +298,9 @@ Framework.GetHunger = function(src)
|
|||||||
return newHunger
|
return newHunger
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---This will return a boolean if the player is dead or in last stand.
|
||||||
|
---@param src number
|
||||||
|
---@return boolean|nil
|
||||||
Framework.GetIsPlayerDead = function(src)
|
Framework.GetIsPlayerDead = function(src)
|
||||||
local player = Framework.GetPlayer(src)
|
local player = Framework.GetPlayer(src)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
@@ -276,6 +308,9 @@ Framework.GetIsPlayerDead = function(src)
|
|||||||
return playerData.metadata.isdead or playerData.metadata.inlaststand or false
|
return playerData.metadata.isdead or playerData.metadata.inlaststand or false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---This will revive a player, if the player is dead or in last stand.
|
||||||
|
---@param src number
|
||||||
|
---@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
|
||||||
@@ -297,6 +332,8 @@ end
|
|||||||
|
|
||||||
-- Framework.GetPlayerPhone(src)
|
-- Framework.GetPlayerPhone(src)
|
||||||
-- Returns the phone number of the player.
|
-- Returns the phone number of the player.
|
||||||
|
---@param src number
|
||||||
|
---@return string | nil
|
||||||
Framework.GetPlayerPhone = function(src)
|
Framework.GetPlayerPhone = function(src)
|
||||||
local player = Framework.GetPlayer(src)
|
local player = Framework.GetPlayer(src)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
@@ -306,6 +343,8 @@ end
|
|||||||
|
|
||||||
-- Framework.GetPlayerGang(src)
|
-- Framework.GetPlayerGang(src)
|
||||||
-- Returns the gang name of the player.
|
-- Returns the gang name of the player.
|
||||||
|
---@param src number
|
||||||
|
---@return string | nil
|
||||||
Framework.GetPlayerGang = function(src)
|
Framework.GetPlayerGang = function(src)
|
||||||
local player = Framework.GetPlayer(src)
|
local player = Framework.GetPlayer(src)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
@@ -342,6 +381,7 @@ Framework.GetPlayerJob = function(src)
|
|||||||
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
|
---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 | nil
|
||||||
Framework.GetPlayerJobData = function(src)
|
Framework.GetPlayerJobData = function(src)
|
||||||
local player = Framework.GetPlayer(src)
|
local player = Framework.GetPlayer(src)
|
||||||
@@ -373,12 +413,13 @@ end
|
|||||||
---This will toggle a players duty status
|
---This will toggle a players duty status
|
||||||
---@param src number
|
---@param src number
|
||||||
---@param status boolean
|
---@param status boolean
|
||||||
---@return nil
|
---@return boolean
|
||||||
Framework.SetPlayerDuty = function(src, status)
|
Framework.SetPlayerDuty = function(src, status)
|
||||||
local player = Framework.GetPlayer(src)
|
local player = Framework.GetPlayer(src)
|
||||||
if not player then return end
|
if not player then return false end
|
||||||
player.Functions.SetJobDuty(status)
|
player.Functions.SetJobDuty(status)
|
||||||
TriggerEvent('QBCore:Server:SetDuty', src, player.PlayerData.job.onduty)
|
TriggerEvent('QBCore:Server:SetDuty', src, player.PlayerData.job.onduty)
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Sets the player's job to the specified name and grade.
|
-- Sets the player's job to the specified name and grade.
|
||||||
@@ -430,27 +471,42 @@ end
|
|||||||
|
|
||||||
-- Framework.AddItem(src, item, amount, slot, metadata)
|
-- Framework.AddItem(src, item, amount, slot, metadata)
|
||||||
-- Adds the specified item to the player's inventory.
|
-- 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)
|
Framework.AddItem = function(src, item, amount, slot, metadata)
|
||||||
local player = Framework.GetPlayer(src)
|
local player = Framework.GetPlayer(src)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src,
|
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, { action = "add", item = item, count = amount, slot = slot, metadata = metadata })
|
||||||
{ action = "add", item = item, count = amount, slot = slot, metadata = metadata })
|
|
||||||
return player.Functions.AddItem(item, amount, slot, metadata)
|
return player.Functions.AddItem(item, amount, slot, metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Framework.RemoveItem(src, item, amount, slot, metadata)
|
-- Framework.RemoveItem(src, item, amount, slot, metadata)
|
||||||
-- Removes the specified item from the player's inventory.
|
-- Removes the specified item from the player's inventory.
|
||||||
|
---@param src number
|
||||||
|
---@param item string
|
||||||
|
---@param amount number
|
||||||
|
---@param slot number
|
||||||
|
---@param metadata table
|
||||||
|
---@return boolean | nil
|
||||||
Framework.RemoveItem = function(src, item, amount, slot, metadata)
|
Framework.RemoveItem = function(src, item, amount, slot, metadata)
|
||||||
local player = Framework.GetPlayer(src)
|
local player = Framework.GetPlayer(src)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src,
|
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, { action = "remove", item = item, count = amount, slot = slot, metadata = metadata })
|
||||||
{ action = "remove", item = item, count = amount, slot = slot, metadata = metadata })
|
|
||||||
return player.Functions.RemoveItem(item, amount, slot or nil)
|
return player.Functions.RemoveItem(item, amount, slot or nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Framework.SetMetadata(src, item, slot, metadata)
|
-- Framework.SetMetadata(src, item, slot, metadata)
|
||||||
-- Sets the metadata for the specified item in the player's inventory.
|
-- Sets the metadata for the specified item in the player's inventory.
|
||||||
-- Notes, this is kinda a jank workaround. with the framework aside from updating the entire table theres not really a better way
|
-- Notes, this is kinda a jank workaround. with the framework aside from updating the entire table theres not really a better way
|
||||||
|
---@param src number
|
||||||
|
---@param item string
|
||||||
|
---@param slot number
|
||||||
|
---@param metadata table
|
||||||
|
---@return boolean | nil
|
||||||
Framework.SetMetadata = function(src, item, slot, metadata)
|
Framework.SetMetadata = function(src, item, slot, metadata)
|
||||||
local player = Framework.GetPlayer(src)
|
local player = Framework.GetPlayer(src)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
@@ -474,8 +530,7 @@ end
|
|||||||
---@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 player_vehicles WHERE citizenid = '" ..
|
local result = MySQL.Sync.fetchAll("SELECT vehicle, plate FROM player_vehicles WHERE citizenid = '" .. citizenId .. "'")
|
||||||
citizenId .. "'")
|
|
||||||
local vehicles = {}
|
local vehicles = {}
|
||||||
for i = 1, #result do
|
for i = 1, #result do
|
||||||
local vehicle = result[i].vehicle
|
local vehicle = result[i].vehicle
|
||||||
@@ -487,6 +542,8 @@ end
|
|||||||
|
|
||||||
-- Framework.RegisterUsableItem(item, cb)
|
-- Framework.RegisterUsableItem(item, cb)
|
||||||
-- Registers a usable item with a callback function.
|
-- Registers a usable item with a callback 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
|
||||||
|
|||||||
@@ -5,18 +5,27 @@ QBox = exports.qbx_core
|
|||||||
|
|
||||||
Framework = Framework or {}
|
Framework = Framework or {}
|
||||||
|
|
||||||
|
---This will get the name of the framework being used (if a supported framework).
|
||||||
|
---@return string
|
||||||
Framework.GetFrameworkName = function()
|
Framework.GetFrameworkName = function()
|
||||||
return 'qbx_core'
|
return 'qbx_core'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---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.
|
||||||
|
---@return table
|
||||||
Framework.GetPlayerData = function()
|
Framework.GetPlayerData = function()
|
||||||
return QBox.GetPlayerData()
|
return QBox.GetPlayerData()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---This will return a table of all the jobs in the framework.
|
||||||
|
---@return table
|
||||||
Framework.GetFrameworkJobs = function()
|
Framework.GetFrameworkJobs = function()
|
||||||
return QBox.GetJobs()
|
return QBox.GetJobs()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---This will get the players birth date
|
||||||
|
---@return string
|
||||||
Framework.GetPlayerDob = function()
|
Framework.GetPlayerDob = function()
|
||||||
local playerData = Framework.GetPlayerData()
|
local playerData = Framework.GetPlayerData()
|
||||||
return playerData.charinfo.birthdate
|
return playerData.charinfo.birthdate
|
||||||
@@ -24,11 +33,10 @@ end
|
|||||||
|
|
||||||
---Will Display the help text message on the screen
|
---Will Display the help text message on the screen
|
||||||
---@param message string
|
---@param message string
|
||||||
---@param _ unknown
|
---@param position string
|
||||||
---@return nil
|
---@return nil
|
||||||
Framework.ShowHelpText = function(message, _)
|
Framework.ShowHelpText = function(message, position)
|
||||||
if _ == nil then _ = 'left-center' end
|
return exports.ox_lib:showTextUI(message, { position = position or 'top-center' })
|
||||||
return exports.ox_lib:showTextUI(message, { position = _position })
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will hide the help text message on the screen
|
---This will hide the help text message on the screen
|
||||||
@@ -37,19 +45,32 @@ Framework.HideHelpText = function()
|
|||||||
return exports.ox_lib:hideTextUI()
|
return exports.ox_lib:hideTextUI()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---This will return the players metadata for the specified metadata key.
|
||||||
|
---@param metadata table | string
|
||||||
|
---@return table | string | number | boolean
|
||||||
Framework.GetPlayerMetaData = function(metadata)
|
Framework.GetPlayerMetaData = function(metadata)
|
||||||
local playerData = Framework.GetPlayerData()
|
local playerData = Framework.GetPlayerData()
|
||||||
return playerData.metadata[metadata]
|
return playerData.metadata[metadata]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---This will send a notification to the player.
|
||||||
|
---@param message string
|
||||||
|
---@param type string
|
||||||
|
---@param time number
|
||||||
|
---@return nil
|
||||||
Framework.Notify = function(message, type, time)
|
Framework.Notify = function(message, type, time)
|
||||||
return QBox:Notify("Notification", type, time, message)
|
return QBox:Notify("Notification", type, time, message)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---This will get the players identifier (citizenid) etc.
|
||||||
|
---@return string
|
||||||
Framework.GetPlayerIdentifier = function()
|
Framework.GetPlayerIdentifier = function()
|
||||||
return Framework.GetPlayerData().citizenid
|
return Framework.GetPlayerData().citizenid
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---This will get the players name (first and last).
|
||||||
|
---@return string
|
||||||
|
---@return string
|
||||||
Framework.GetPlayerName = function()
|
Framework.GetPlayerName = function()
|
||||||
local playerData = Framework.GetPlayerData()
|
local playerData = Framework.GetPlayerData()
|
||||||
return playerData.charinfo.firstname, playerData.charinfo.lastname
|
return playerData.charinfo.firstname, playerData.charinfo.lastname
|
||||||
@@ -81,11 +102,13 @@ Framework.GetPlayerJobData = function()
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---This will return the players inventory as a table in the ox_inventory style flormat.
|
||||||
|
---@return table
|
||||||
Framework.GetPlayerInventory = function()
|
Framework.GetPlayerInventory = function()
|
||||||
return Framework.GetPlayerData().items
|
return Framework.GetPlayerData().items
|
||||||
end
|
end
|
||||||
|
|
||||||
---comment
|
---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)
|
||||||
@@ -93,6 +116,8 @@ Framework.GetItemCount = function(item)
|
|||||||
return 0, print("Community_bridge:WARN: GetItemCount is not implemented for this framework, please use the inventory module to get the item count. If you are using a diffrent inventory please let us know so we can bridge it and have less nonsense.")
|
return 0, print("Community_bridge:WARN: GetItemCount is not implemented for this framework, please use the inventory module to get the item count. If you are using a diffrent inventory please let us know so we can bridge it and have less nonsense.")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---This will get a players dead status.
|
||||||
|
---@return boolean
|
||||||
Framework.GetIsPlayerDead = function()
|
Framework.GetIsPlayerDead = function()
|
||||||
local platerData = Framework.GetPlayerData()
|
local platerData = Framework.GetPlayerData()
|
||||||
return platerData.metadata["isdead"] or platerData.metadata["inlaststand"]
|
return platerData.metadata["isdead"] or platerData.metadata["inlaststand"]
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ end
|
|||||||
|
|
||||||
---Returns the player date of birth.
|
---Returns the player date of birth.
|
||||||
---@param src number
|
---@param src number
|
||||||
---@return string
|
---@return string|nil
|
||||||
Framework.GetPlayerDob = function(src)
|
Framework.GetPlayerDob = function(src)
|
||||||
local player = Framework.GetPlayer(src)
|
local player = Framework.GetPlayer(src)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
@@ -69,11 +69,12 @@ Framework.GetPlayerName = function(src)
|
|||||||
return playerData.charinfo.firstname, playerData.charinfo.lastname
|
return playerData.charinfo.firstname, playerData.charinfo.lastname
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Returns a table of items matching the specified name and if passed metadata from the player's inventory.
|
---Returns 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 metadata table
|
---@param metadata table
|
||||||
---@return table
|
---@return table|nil
|
||||||
Framework.GetItem = function(src, item, metadata)
|
Framework.GetItem = function(src, item, metadata)
|
||||||
local player = Framework.GetPlayer(src)
|
local player = Framework.GetPlayer(src)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
@@ -203,7 +204,7 @@ Framework.AddHunger = function(src, value)
|
|||||||
return newHunger
|
return newHunger
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 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
|
||||||
@@ -228,6 +229,9 @@ Framework.GetHunger = function(src)
|
|||||||
return newHunger
|
return newHunger
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---This will return a boolean if the player is dead or in last stand.
|
||||||
|
---@param src number
|
||||||
|
---@return boolean|nil
|
||||||
Framework.GetIsPlayerDead = function(src)
|
Framework.GetIsPlayerDead = function(src)
|
||||||
local player = Framework.GetPlayer(src)
|
local player = Framework.GetPlayer(src)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
@@ -235,6 +239,9 @@ Framework.GetIsPlayerDead = function(src)
|
|||||||
return playerData.metadata.isdead or false
|
return playerData.metadata.isdead or false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---This will revive a player, if the player is dead or in last stand.
|
||||||
|
---@param src number
|
||||||
|
---@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
|
||||||
@@ -244,7 +251,7 @@ end
|
|||||||
|
|
||||||
---This will return the players thirst level.
|
---This will return the players thirst level.
|
||||||
---@param src number
|
---@param src number
|
||||||
---@return number
|
---@return number| nil
|
||||||
Framework.GetThirst = function(src)
|
Framework.GetThirst = function(src)
|
||||||
local player = Framework.GetPlayer(src)
|
local player = Framework.GetPlayer(src)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
@@ -299,6 +306,7 @@ Framework.GetPlayerJob = function(src)
|
|||||||
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
|
---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 | nil
|
||||||
Framework.GetPlayerJobData = function(src)
|
Framework.GetPlayerJobData = function(src)
|
||||||
local player = Framework.GetPlayer(src)
|
local player = Framework.GetPlayer(src)
|
||||||
@@ -395,8 +403,7 @@ end
|
|||||||
Framework.AddItem = function(src, item, amount, slot, metadata)
|
Framework.AddItem = function(src, item, amount, slot, metadata)
|
||||||
local player = Framework.GetPlayer(src)
|
local player = Framework.GetPlayer(src)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src,
|
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, { action = "add", item = item, count = amount, slot = slot, metadata = metadata })
|
||||||
{ action = "add", item = item, count = amount, slot = slot, metadata = metadata })
|
|
||||||
return player.Functions.AddItem(item, amount, slot, metadata)
|
return player.Functions.AddItem(item, amount, slot, metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -410,13 +417,12 @@ end
|
|||||||
Framework.RemoveItem = function(src, item, amount, slot, metadata)
|
Framework.RemoveItem = function(src, item, amount, slot, metadata)
|
||||||
local player = Framework.GetPlayer(src)
|
local player = Framework.GetPlayer(src)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src,
|
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, { action = "remove", item = item, count = amount, slot = slot, metadata = metadata })
|
||||||
{ action = "remove", item = item, count = amount, slot = slot, metadata = metadata })
|
|
||||||
return player.Functions.RemoveItem(item, amount, slot)
|
return player.Functions.RemoveItem(item, amount, slot)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Sets the metadata for the specified item in the player's inventory.
|
---Sets the metadata for the specified item in the player's inventory.
|
||||||
-----@param src number
|
---@param src number
|
||||||
---@param item string
|
---@param item string
|
||||||
---@param slot number
|
---@param slot number
|
||||||
---@param metadata table
|
---@param metadata table
|
||||||
@@ -433,8 +439,7 @@ end
|
|||||||
---@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 player_vehicles WHERE citizenid = '" ..
|
local result = MySQL.Sync.fetchAll("SELECT vehicle, plate FROM player_vehicles WHERE citizenid = '" .. citizenId .. "'")
|
||||||
citizenId .. "'")
|
|
||||||
local vehicles = {}
|
local vehicles = {}
|
||||||
for i = 1, #result do
|
for i = 1, #result do
|
||||||
local vehicle = result[i].vehicle
|
local vehicle = result[i].vehicle
|
||||||
|
|||||||
+5
-3
@@ -2,11 +2,13 @@
|
|||||||
if GetResourceState('Renewed-Banking') == 'missing' then return end
|
if GetResourceState('Renewed-Banking') == 'missing' then return end
|
||||||
Managment = Managment or {}
|
Managment = Managment or {}
|
||||||
|
|
||||||
|
local renewed = exports['Renewed-Banking']
|
||||||
|
|
||||||
---This will return a table with account details
|
---This will return a table with account details
|
||||||
---@param account string
|
---@param account string
|
||||||
---@return table
|
---@return table
|
||||||
Managment.GetAccountMoney = function(account)
|
Managment.GetAccountMoney = function(account)
|
||||||
return exports['Renewed-Banking']:getAccountMoney(account)
|
return renewed:getAccountMoney(account)
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will add money to the specified account of the passed amount
|
---This will add money to the specified account of the passed amount
|
||||||
@@ -15,7 +17,7 @@ end
|
|||||||
---@param _ string
|
---@param _ string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Managment.AddAccountMoney = function(account, amount, _)
|
Managment.AddAccountMoney = function(account, amount, _)
|
||||||
return exports['Renewed-Banking']:addAccountMoney(account, amount)
|
return renewed:addAccountMoney(account, amount)
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will remove money from the specified account of the passed amount
|
---This will remove money from the specified account of the passed amount
|
||||||
@@ -24,7 +26,7 @@ end
|
|||||||
---@param _ string
|
---@param _ string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Managment.RemoveAccountMoney = function(account, amount, _)
|
Managment.RemoveAccountMoney = function(account, amount, _)
|
||||||
return exports['Renewed-Banking']:removeAccountMoney(account, amount)
|
return renewed:removeAccountMoney(account, amount)
|
||||||
end
|
end
|
||||||
|
|
||||||
return Managment
|
return Managment
|
||||||
File renamed without changes.
File renamed without changes.
Reference in new issue
Block a user