docs: refine framework notes, params, and return documentation
This commit is contained in:
1 parent
38ce2e8f1e
commit
7fc9ee4956
6 files changed
+257
-80
No files matched your search
@@ -5,18 +5,27 @@ QBox = exports.qbx_core
|
||||
|
||||
Framework = Framework or {}
|
||||
|
||||
---This will get the name of the framework being used (if a supported framework).
|
||||
---@return string
|
||||
Framework.GetFrameworkName = function()
|
||||
return 'qbx_core'
|
||||
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()
|
||||
return QBox.GetPlayerData()
|
||||
end
|
||||
|
||||
---This will return a table of all the jobs in the framework.
|
||||
---@return table
|
||||
Framework.GetFrameworkJobs = function()
|
||||
return QBox.GetJobs()
|
||||
end
|
||||
|
||||
---This will get the players birth date
|
||||
---@return string
|
||||
Framework.GetPlayerDob = function()
|
||||
local playerData = Framework.GetPlayerData()
|
||||
return playerData.charinfo.birthdate
|
||||
@@ -24,11 +33,10 @@ end
|
||||
|
||||
---Will Display the help text message on the screen
|
||||
---@param message string
|
||||
---@param _ unknown
|
||||
---@param position string
|
||||
---@return nil
|
||||
Framework.ShowHelpText = function(message, _)
|
||||
if _ == nil then _ = 'left-center' end
|
||||
return exports.ox_lib:showTextUI(message, { position = _position })
|
||||
Framework.ShowHelpText = function(message, position)
|
||||
return exports.ox_lib:showTextUI(message, { position = position or 'top-center' })
|
||||
end
|
||||
|
||||
---This will hide the help text message on the screen
|
||||
@@ -37,19 +45,32 @@ Framework.HideHelpText = function()
|
||||
return exports.ox_lib:hideTextUI()
|
||||
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)
|
||||
local playerData = Framework.GetPlayerData()
|
||||
return playerData.metadata[metadata]
|
||||
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)
|
||||
return QBox:Notify("Notification", type, time, message)
|
||||
end
|
||||
|
||||
---This will get the players identifier (citizenid) etc.
|
||||
---@return string
|
||||
Framework.GetPlayerIdentifier = function()
|
||||
return Framework.GetPlayerData().citizenid
|
||||
end
|
||||
|
||||
---This will get the players name (first and last).
|
||||
---@return string
|
||||
---@return string
|
||||
Framework.GetPlayerName = function()
|
||||
local playerData = Framework.GetPlayerData()
|
||||
return playerData.charinfo.firstname, playerData.charinfo.lastname
|
||||
@@ -81,11 +102,13 @@ Framework.GetPlayerJobData = function()
|
||||
}
|
||||
end
|
||||
|
||||
---This will return the players inventory as a table in the ox_inventory style flormat.
|
||||
---@return table
|
||||
Framework.GetPlayerInventory = function()
|
||||
return Framework.GetPlayerData().items
|
||||
end
|
||||
|
||||
---comment
|
||||
---This will return the item count for the specified item in the players inventory.
|
||||
---@param item string
|
||||
---@return number
|
||||
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.")
|
||||
end
|
||||
|
||||
---This will get a players dead status.
|
||||
---@return boolean
|
||||
Framework.GetIsPlayerDead = function()
|
||||
local platerData = Framework.GetPlayerData()
|
||||
return platerData.metadata["isdead"] or platerData.metadata["inlaststand"]
|
||||
|
||||
@@ -13,7 +13,7 @@ end
|
||||
|
||||
---Returns the player date of birth.
|
||||
---@param src number
|
||||
---@return string
|
||||
---@return string|nil
|
||||
Framework.GetPlayerDob = function(src)
|
||||
local player = Framework.GetPlayer(src)
|
||||
if not player then return end
|
||||
@@ -69,11 +69,12 @@ Framework.GetPlayerName = function(src)
|
||||
return playerData.charinfo.firstname, playerData.charinfo.lastname
|
||||
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 item string
|
||||
---@param metadata table
|
||||
---@return table
|
||||
---@return table|nil
|
||||
Framework.GetItem = function(src, item, metadata)
|
||||
local player = Framework.GetPlayer(src)
|
||||
if not player then return end
|
||||
@@ -203,7 +204,7 @@ Framework.AddHunger = function(src, value)
|
||||
return newHunger
|
||||
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 value number
|
||||
---@return number | nil
|
||||
@@ -228,6 +229,9 @@ Framework.GetHunger = function(src)
|
||||
return newHunger
|
||||
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)
|
||||
local player = Framework.GetPlayer(src)
|
||||
if not player then return end
|
||||
@@ -235,6 +239,9 @@ Framework.GetIsPlayerDead = function(src)
|
||||
return playerData.metadata.isdead or false
|
||||
end
|
||||
|
||||
---This will revive a player, if the player is dead or in last stand.
|
||||
---@param src number
|
||||
---@return boolean
|
||||
Framework.RevivePlayer = function(src)
|
||||
src = tonumber(src)
|
||||
if not src then return false end
|
||||
@@ -244,7 +251,7 @@ end
|
||||
|
||||
---This will return the players thirst level.
|
||||
---@param src number
|
||||
---@return number
|
||||
---@return number| nil
|
||||
Framework.GetThirst = function(src)
|
||||
local player = Framework.GetPlayer(src)
|
||||
if not player then return end
|
||||
@@ -299,6 +306,7 @@ Framework.GetPlayerJob = function(src)
|
||||
end
|
||||
|
||||
---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
|
||||
Framework.GetPlayerJobData = function(src)
|
||||
local player = Framework.GetPlayer(src)
|
||||
@@ -395,8 +403,7 @@ end
|
||||
Framework.AddItem = function(src, item, amount, slot, metadata)
|
||||
local player = Framework.GetPlayer(src)
|
||||
if not player then return end
|
||||
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src,
|
||||
{ action = "add", item = item, count = amount, slot = slot, metadata = metadata })
|
||||
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, { action = "add", item = item, count = amount, slot = slot, metadata = metadata })
|
||||
return player.Functions.AddItem(item, amount, slot, metadata)
|
||||
end
|
||||
|
||||
@@ -410,13 +417,12 @@ end
|
||||
Framework.RemoveItem = function(src, item, amount, slot, metadata)
|
||||
local player = Framework.GetPlayer(src)
|
||||
if not player then return end
|
||||
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src,
|
||||
{ action = "remove", item = item, count = amount, slot = slot, metadata = metadata })
|
||||
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, { action = "remove", item = item, count = amount, slot = slot, metadata = metadata })
|
||||
return player.Functions.RemoveItem(item, amount, slot)
|
||||
end
|
||||
|
||||
---Sets the metadata for the specified item in the player's inventory.
|
||||
-----@param src number
|
||||
---@param src number
|
||||
---@param item string
|
||||
---@param slot number
|
||||
---@param metadata table
|
||||
@@ -433,8 +439,7 @@ end
|
||||
---@return table
|
||||
Framework.GetOwnedVehicles = function(src)
|
||||
local citizenId = Framework.GetPlayerIdentifier(src)
|
||||
local result = MySQL.Sync.fetchAll("SELECT vehicle, plate FROM player_vehicles WHERE citizenid = '" ..
|
||||
citizenId .. "'")
|
||||
local result = MySQL.Sync.fetchAll("SELECT vehicle, plate FROM player_vehicles WHERE citizenid = '" .. citizenId .. "'")
|
||||
local vehicles = {}
|
||||
for i = 1, #result do
|
||||
local vehicle = result[i].vehicle
|
||||
|
||||
Reference in new issue
Block a user