chore(intellisense): improve parameter annotations and add missing comments

Touched up incorrect or missing Intellisense parameter annotations across several functions. Added some missing descriptions to improve editor support. Still more to do, but this is a small step forward for overall developer workflow. Also small fix in picklexp
This commit is contained in:
MrNewb committed 2025-06-07 22:50:13 -04:00
1 parent 866283162b
commit c71a261115
88 files changed
+339 -286

No files matched your search

+3 -3
View File
@@ -22,9 +22,9 @@ Clothing.SetAppearance = function(src, data)
end
--- Sets a player's appearance based on gender-specific data
--- @param src number The server ID of the player
--- @param data table Table containing separate appearance data for male and female characters
--- @return table|nil Appearance updated player appearance data or nil if failed
---@param src number The server ID of the player
---@param data table Table containing separate appearance data for male and female characters
---@return table|nil Appearance updated player appearance data or nil if failed
function Clothing.SetAppearanceExt(src, data)
local tbl = Clothing.IsMale(src) and data.male or data.female
Clothing.SetAppearance(src, tbl)
+1 -1
View File
@@ -1,4 +1,4 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('esx_skin') == 'missing' then return end
Clothing = Clothing or {}
+30 -28
View File
@@ -1,3 +1,4 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('esx_skin') == 'missing' then return end
Clothing = Clothing or {}
Clothing.Players = {}
@@ -6,9 +7,9 @@ Callback = Callback or Require("lib/utility/shared/callbacks.lua")
Table = Table or Require('lib/utility/shared/tables.lua')
ESX = ESX or exports['es_extended']:getSharedObject()
--- Internal function to get the full appearance data including skin, model, and converted format
--- @param src number The server ID of the player
--- @return table|nil The player's full appearance data or nil if not found
---Internal function to get the full appearance data including skin, model, and converted format
---@param src number The server ID of the player
---@return table|nil The player's full appearance data or nil if not found
function Clothing.GetFullAppearanceData(src)
src = src and tonumber(src)
assert(src, "src is nil")
@@ -36,10 +37,10 @@ function Clothing.GetFullAppearanceData(src)
return Clothing.Players[citId]
end
--- Retrieves a player's converted appearance data for easy use across modules
--- @param src number The server ID of the player
--- @param fullData boolean Optional - If true, returns the full data object including skin and model
--- @return table|nil The player's converted appearance data or full appearance data if fullData=true
---Retrieves a player's converted appearance data for easy use across modules
---@param src number The server ID of the player
---@param fullData boolean Optional - If true, returns the full data object including skin and model
---@return table|nil The player's converted appearance data or full appearance data if fullData=true
function Clothing.GetAppearance(src, fullData)
if fullData then
return Clothing.GetFullAppearanceData(src)
@@ -49,7 +50,8 @@ function Clothing.GetAppearance(src, fullData)
return completeData.converted
end
---This will save the player's current appearance to the database
---@param src number|string
function Clothing.Save(src)
src = src and tonumber(src)
assert(src, "src is nil")
@@ -66,11 +68,11 @@ function Clothing.Save(src)
citId
})
end
--- Sets a player's appearance based on the provided data
--- @param src number The server ID of the player
--- @param data table The appearance data to apply
--- @param updateBackup boolean Whether to update the backup appearance data
--- @return table|nil The updated player appearance data or nil if failed
---Sets a player's appearance based on the provided data
---@param src number The server ID of the player
---@param data table The appearance data to apply
---@param updateBackup boolean Whether to update the backup appearance data
---@return table|nil The updated player appearance data or nil if failed
function Clothing.SetAppearance(src, data, updateBackup, save)
src = src and tonumber(src)
assert(src, "src is nil")
@@ -113,17 +115,17 @@ function Clothing.SetAppearance(src, data, updateBackup, save)
end
--- Sets a player's appearance based on gender-specific data
--- @param src number The server ID of the player
--- @param data table Table containing separate appearance data for male and female characters
--- @return table|nil Appearance updated player appearance data or nil if failed
---@param src number The server ID of the player
---@param data table Table containing separate appearance data for male and female characters
---@return table|nil Appearance updated player appearance data or nil if failed
function Clothing.SetAppearanceExt(src, data)
local tbl = Clothing.IsMale(src) and data.male or data.female
Clothing.SetAppearance(src, tbl)
end
--- Reverts a player's appearance to their backup appearance
--- @param src number The server ID of the player
--- @return boolean|nil Returns true if successful or nil if failed
---Reverts a player's appearance to their backup appearance
---@param src number The server ID of the player
---@return boolean|nil Returns true if successful or nil if failed
function Clothing.Revert(src)
src = src and tonumber(src)
assert(src, "src is nil")
@@ -134,15 +136,16 @@ function Clothing.Revert(src)
return Clothing.SetAppearance(src, backup)
end
---This will open the menu for the passed src
---@param src number|string
function Clothing.OpenMenu(src)
src = src and tonumber(src)
assert(src, "src is nil")
TriggerClientEvent('esx_skin:openMenu', src)
end
--- Event handler for when a player loads into the server
--- Caches the player's appearance data
---Event handler for when a player loads into the server
---Caches the player's appearance data
AddEventHandler('community_bridge:Server:OnPlayerLoaded', function(src)
src = src and tonumber(src)
assert(src, "src is nil")
@@ -150,8 +153,8 @@ AddEventHandler('community_bridge:Server:OnPlayerLoaded', function(src)
Clothing.GetFullAppearanceData(src)
end)
--- Event handler for when a player disconnects from the server
--- Removes the player's appearance data from the cache
---Event handler for when a player disconnects from the server
---Removes the player's appearance data from the cache
AddEventHandler('community_bridge:Server:OnPlayerUnload', function(src)
src = src and tonumber(src)
assert(src, "src is nil")
@@ -161,8 +164,8 @@ end)
--- Event handler for when the resource starts
--- Caches appearance data for all currently connected players
---Event handler for when the resource starts
---Caches appearance data for all currently connected players
AddEventHandler('onResourceStart', function(resource)
if resource ~= GetCurrentResourceName() then return end
for _, playerId in ipairs(GetPlayers()) do
@@ -174,13 +177,12 @@ AddEventHandler('onResourceStart', function(resource)
end
end)
--- Callback handler for retrieving a player's appearance data
---Callback handler for retrieving a player's appearance data
Callback.Register('community_bridge:cb:GetAppearance', function(source)
local src = source
return Clothing.GetAppearance(src)
end)
RegisterCommand('clothing:debug', function(source, args, rawCommand)
local src = source
Clothing.SetAppearance(src, {
+7 -7
View File
@@ -1,4 +1,4 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('esx_skin') == 'missing' then return end
Clothing = Clothing or {}
@@ -91,14 +91,14 @@ end
function Props.ConvertFromDefault(defaultProps)
local returnProps = {}
for index, propData in pairs(defaultProps or {}) do
for index, propData in pairs(defaultProps or {}) do
local propId = Props.Map[propData.prop_id]
if propId then
returnProps[propId .. '_1'] = propData.drawable
returnProps[propId .. '_2'] = propData.texture
returnProps[propId .. '_2'] = propData.texture
end
end
return returnProps
return returnProps
end
function Props.ConvertToDefault(esxProps)
@@ -115,14 +115,14 @@ function Props.ConvertToDefault(esxProps)
returnProps[propId] = returnProps[propId] or {}
returnProps[propId].prop_id = propId
returnProps[propId].drawable = propData
returnProps[propId].texture = returnProps[propId].texture or 0
returnProps[propId].texture = returnProps[propId].texture or 0
end
end
table.sort(returnProps, function(a, b)
return a.prop_id < b.prop_id
end)
end
return returnProps
return returnProps
end
function Clothing.ConvertFromDefault(defaultClothing)
@@ -131,7 +131,7 @@ function Clothing.ConvertFromDefault(defaultClothing)
for propsIndex, propData in pairs(props) do
components[propsIndex] = propData
end
end
return components --skin
end
+1 -1
View File
@@ -1,4 +1,4 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('fivem-appearance') == 'missing' then return end
Clothing = Clothing or {}
+15 -14
View File
@@ -1,3 +1,4 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('fivem-appearance') == 'missing' then return end
Clothing = Clothing or {}
Clothing.Players = {}
@@ -6,8 +7,8 @@ Callback = Callback or Require("lib/utility/shared/callbacks.lua")
Table = Table or Require('lib/utility/shared/tables.lua')
--- Internal function to get the full appearance data including skin, model, and converted format
--- @param src number The server ID of the player
--- @return table|nil The player's full appearance data or nil if not found
---@param src number The server ID of the player
---@return table|nil The player's full appearance data or nil if not found
function Clothing.GetFullAppearanceData(src)
src = src and tonumber(src)
assert(src, "src is nil")
@@ -34,9 +35,9 @@ function Clothing.GetFullAppearanceData(src)
end
--- Retrieves a player's converted appearance data for easy use across modules
--- @param src number The server ID of the player
--- @param fullData boolean Optional - If true, returns the full data object including skin and model
--- @return table|nil The player's converted appearance data or full appearance data if fullData=true
---@param src number The server ID of the player
---@param fullData boolean Optional - If true, returns the full data object including skin and model
---@return table|nil The player's converted appearance data or full appearance data if fullData=true
function Clothing.GetAppearance(src, fullData)
if fullData then
return Clothing.GetFullAppearanceData(src)
@@ -47,10 +48,10 @@ function Clothing.GetAppearance(src, fullData)
end
--- Sets a player's appearance based on the provided data
--- @param src number The server ID of the player
--- @param data table The appearance data to apply
--- @param updateBackup boolean Whether to update the backup appearance data
--- @return table|nil The updated player appearance data or nil if failed
---@param src number The server ID of the player
---@param data table The appearance data to apply
---@param updateBackup boolean Whether to update the backup appearance data
---@return table|nil The updated player appearance data or nil if failed
function Clothing.SetAppearance(src, data, updateBackup, save)
src = src and tonumber(src)
assert(src, "src is nil")
@@ -89,17 +90,17 @@ function Clothing.SetAppearance(src, data, updateBackup, save)
end
--- Sets a player's appearance based on gender-specific data
--- @param src number The server ID of the player
--- @param data table Table containing separate appearance data for male and female characters
--- @return table|nil Appearance updated player appearance data or nil if failed
---@param src number The server ID of the player
---@param data table Table containing separate appearance data for male and female characters
---@return table|nil Appearance updated player appearance data or nil if failed
function Clothing.SetAppearanceExt(src, data)
local tbl = Clothing.IsMale(src) and data.male or data.female
Clothing.SetAppearance(src, tbl)
end
--- Reverts a player's appearance to their backup appearance
--- @param src number The server ID of the player
--- @return boolean|nil Returns true if successful or nil if failed
---@param src number The server ID of the player
---@return boolean|nil Returns true if successful or nil if failed
function Clothing.Revert(src)
src = src and tonumber(src)
local currentClothing = Clothing.GetFullAppearanceData(src)
@@ -1,3 +1,4 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('illenium-appearance') == 'missing' then return end
Clothing = Clothing or {}
+15 -14
View File
@@ -1,3 +1,4 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('illenium-appearance') == 'missing' then return end
Clothing = Clothing or {}
Clothing.Players = {}
@@ -6,8 +7,8 @@ Callback = Callback or Require("lib/utility/shared/callbacks.lua")
Table = Table or Require('lib/utility/shared/tables.lua')
--- Internal function to get the full appearance data including skin, model, and converted format
--- @param src number The server ID of the player
--- @return table|nil The player's full appearance data or nil if not found
---@param src number The server ID of the player
---@return table|nil The player's full appearance data or nil if not found
function Clothing.GetFullAppearanceData(src)
src = src and tonumber(src)
assert(src, "src is nil")
@@ -34,9 +35,9 @@ function Clothing.GetFullAppearanceData(src)
end
--- Retrieves a player's converted appearance data for easy use across modules
--- @param src number The server ID of the player
--- @param fullData boolean Optional - If true, returns the full data object including skin and model
--- @return table|nil The player's converted appearance data or full appearance data if fullData=true
---@param src number The server ID of the player
---@param fullData boolean Optional - If true, returns the full data object including skin and model
---@return table|nil The player's converted appearance data or full appearance data if fullData=true
function Clothing.GetAppearance(src, fullData)
if fullData then
return Clothing.GetFullAppearanceData(src)
@@ -47,10 +48,10 @@ function Clothing.GetAppearance(src, fullData)
end
--- Sets a player's appearance based on the provided data
--- @param src number The server ID of the player
--- @param data table The appearance data to apply
--- @param updateBackup boolean Whether to update the backup appearance data
--- @return table|nil The updated player appearance data or nil if failed
---@param src number The server ID of the player
---@param data table The appearance data to apply
---@param updateBackup boolean Whether to update the backup appearance data
---@return table|nil The updated player appearance data or nil if failed
function Clothing.SetAppearance(src, data, updateBackup, save)
src = src and tonumber(src)
assert(src, "src is nil")
@@ -89,17 +90,17 @@ function Clothing.SetAppearance(src, data, updateBackup, save)
end
--- Sets a player's appearance based on gender-specific data
--- @param src number The server ID of the player
--- @param data table Table containing separate appearance data for male and female characters
--- @return table|nil Appearance updated player appearance data or nil if failed
---@param src number The server ID of the player
---@param data table Table containing separate appearance data for male and female characters
---@return table|nil Appearance updated player appearance data or nil if failed
function Clothing.SetAppearanceExt(src, data)
local tbl = Clothing.IsMale(src) and data.male or data.female
Clothing.SetAppearance(src, tbl)
end
--- Reverts a player's appearance to their backup appearance
--- @param src number The server ID of the player
--- @return boolean|nil Returns true if successful or nil if failed
---@param src number The server ID of the player
---@return boolean|nil Returns true if successful or nil if failed
function Clothing.Revert(src)
src = src and tonumber(src)
assert(src, "src is nil")
+2 -3
View File
@@ -1,8 +1,7 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('qb-clothing') == 'missing' then return end
Clothing = Clothing or {}
function Clothing.OpenMenu()
TriggerEvent('qb-clothing:client:openMenu')
end
end
+18 -19
View File
@@ -1,3 +1,4 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('qb-clothing') == 'missing' then return end
Clothing = Clothing or {}
Clothing.Players = {}
@@ -7,8 +8,8 @@ Table = Table or Require('lib/utility/shared/tables.lua')
QBCore = QBCore or exports['qb-core']:GetCoreObject() -- probably easiest for now to call the Framework module
--- Internal function to get the full appearance data including skin, model, and converted format
--- @param src number The server ID of the player
--- @return table|nil The player's full appearance data or nil if not found
---@param src number The server ID of the player
---@return table|nil The player's full appearance data or nil if not found
function Clothing.GetFullAppearanceData(src)
src = src and tonumber(src)
assert(src, "src is nil")
@@ -37,9 +38,9 @@ function Clothing.GetFullAppearanceData(src)
end
--- Retrieves a player's converted appearance data for easy use across modules
--- @param src number The server ID of the player
--- @param fullData boolean Optional - If true, returns the full data object including skin and model
--- @return table|nil The player's converted appearance data or full appearance data if fullData=true
---@param src number The server ID of the player
---@param fullData boolean Optional - If true, returns the full data object including skin and model
---@return table|nil The player's converted appearance data or full appearance data if fullData=true
function Clothing.GetAppearance(src, fullData)
if fullData then
return Clothing.GetFullAppearanceData(src)
@@ -50,10 +51,10 @@ function Clothing.GetAppearance(src, fullData)
end
--- Sets a player's appearance based on the provided data
--- @param src number The server ID of the player
--- @param data table The appearance data to apply
--- @param updateBackup boolean Whether to update the backup appearance data
--- @return table|nil The updated player appearance data or nil if failed
---@param src number The server ID of the player
---@param data table The appearance data to apply
---@param updateBackup boolean Whether to update the backup appearance data
---@return table|nil The updated player appearance data or nil if failed
function Clothing.SetAppearance(src, data, updateBackup, save)
src = src and tonumber(src)
assert(src, "src is nil")
@@ -94,17 +95,17 @@ function Clothing.SetAppearance(src, data, updateBackup, save)
end
--- Sets a player's appearance based on gender-specific data
--- @param src number The server ID of the player
--- @param data table Table containing separate appearance data for male and female characters
--- @return table|nil Appearance updated player appearance data or nil if failed
---@param src number The server ID of the player
---@param data table Table containing separate appearance data for male and female characters
---@return table|nil Appearance updated player appearance data or nil if failed
function Clothing.SetAppearanceExt(src, data)
local tbl = Clothing.IsMale(src) and data.male or data.female
Clothing.SetAppearance(src, tbl)
end
--- Reverts a player's appearance to their backup appearance
--- @param src number The server ID of the player
--- @return boolean|nil Returns true if successful or nil if failed
---@param src number The server ID of the player
---@return boolean|nil Returns true if successful or nil if failed
function Clothing.Revert(src)
src = src and tonumber(src)
assert(src, "src is nil")
@@ -145,8 +146,6 @@ AddEventHandler('community_bridge:Server:OnPlayerUnload', function(src)
Clothing.Players[strSrc] = nil
end)
--- Event handler for when the resource starts
--- Caches appearance data for all currently connected players
AddEventHandler('onResourceStart', function(resource)
@@ -166,7 +165,7 @@ Callback.Register('community_bridge:cb:GetAppearance', function(source)
return Clothing.GetAppearance(src)
end)
--[[
RegisterCommand('clothing:debug', function(source, args, rawCommand)
local src = source
Clothing.SetAppearance(src, {
@@ -206,7 +205,7 @@ RegisterCommand('clothing:openmenu', function(source, args, rawCommand)
local src = source
Clothing.OpenMenu(src)
end, false)
--]]
-- RegisterCommand('clothing:crowley', function(source, args, rawCommand)
-- local src = source
@@ -236,4 +235,4 @@ end, false)
-- -- {drawable = 0, prop_id = 7, texture = 0},
-- }
-- }, false, true)
-- end, false)
-- end, false)
+2 -2
View File
@@ -92,7 +92,7 @@ end
function Props.ConvertToDefault(qbProps)
local returnProps = {}
for propIndex, propData in pairs(qbProps or {}) do
for propIndex, propData in pairs(qbProps or {}) do
local propId = Props.InverseMap[propIndex]
if propId then
table.insert(returnProps, {
@@ -114,7 +114,7 @@ function Clothing.ConvertFromDefault(defaultClothing)
for propsIndex, propData in pairs(props) do
components[propsIndex] = propData
end
end
return components --skin
end