From 29d75163a9a752785315d479cc2eaa7f06ca2034 Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Tue, 8 Apr 2025 19:10:02 -0400 Subject: [PATCH] intelisense stuff --- lib/utility/shared/ids.lua | 29 ++++++++- lib/utility/shared/prints.lua | 9 +++ modules/clothing/_default/client.lua | 10 +++ modules/dispatch/_default/client/client.lua | 3 + modules/dispatch/lb-tablet/client/client.lua | 2 + modules/doorlock/doors_creator/server.lua | 5 ++ modules/doorlock/ox_doorlock/client.lua | 2 + modules/framework/qb-core/client.lua | 21 +++++++ modules/framework/qb-core/server.lua | 61 +++++++++++++++---- modules/fuel/_defualts/client.lua | 11 +++- modules/inventory/ox_inventory/server.lua | 16 ++--- modules/vehicleKey/_default/client/client.lua | 7 +++ modules/weather/_default/client.lua | 3 +- 13 files changed, 156 insertions(+), 23 deletions(-) diff --git a/lib/utility/shared/ids.lua b/lib/utility/shared/ids.lua index 3091b9b..f0ae840 100644 --- a/lib/utility/shared/ids.lua +++ b/lib/utility/shared/ids.lua @@ -1,5 +1,11 @@ Ids = Ids or {} --- for unique ids + + +---This will generate a unique id. +---@param tbl table +---@param len number +---@param pattern string +---@return string Ids.CreateUniqueId = function(tbl, len, pattern) -- both optional tbl = tbl or {} -- table to check uniqueness. Ids to check against must be the key to the tables value len = len or 8 @@ -21,22 +27,43 @@ Ids.CreateUniqueId = function(tbl, len, pattern) -- both optional return id end + +---This will generate a unique id. +---@param tbl table +---@param len number +---@return string Ids.RandomUpper = function(tbl, len) return Ids.CreateUniqueId(tbl, len, "ABCDEFGHIJKLMNOPQRSTUVWXYZ") end +---This will generate a unique id. +---@param tbl table +---@param len number +---@return string Ids.RandomLower = function(tbl, len) return Ids.CreateUniqueId(tbl, len, "abcdefghijklmnopqrstuvwxyz") end +---This will generate a unique id. +---@param tbl table +---@param len number +---@return string Ids.RandomString = function(tbl, len) return Ids.CreateUniqueId(tbl, len, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") end +---This will generate a unique id. +---@param tbl table +---@param len number +---@return string Ids.RandomNumber = function(tbl, len) return Ids.CreateUniqueId(tbl, len, "0123456789") end +---This will generate a unique id. +---@param tbl table +---@param len number +---@return string Ids.Random = function(tbl, len) return Ids.CreateUniqueId(tbl, len) end diff --git a/lib/utility/shared/prints.lua b/lib/utility/shared/prints.lua index 2fc00ef..6b73522 100644 --- a/lib/utility/shared/prints.lua +++ b/lib/utility/shared/prints.lua @@ -6,18 +6,27 @@ local function printMessage(level, color, message) print(color .. '[' .. level .. ']:', message) end + +---This will print a colored message to the console with the designated prefix. +---@param message string Prints.Info = function(message) printMessage('INFO', '^5', message) end +---This will print a colored message to the console with the designated prefix. +---@param message string Prints.Warn = function(message) printMessage('WARN', '^3', message) end +---This will print a colored message to the console with the designated prefix. +---@param message string Prints.Error = function(message) printMessage('ERROR', '^1', message) end +---This will print a colored message to the console with the designated prefix. +---@param message string Prints.Debug = function(message) printMessage('DEBUG', '^2', message) end diff --git a/modules/clothing/_default/client.lua b/modules/clothing/_default/client.lua index b406e5a..bd35793 100644 --- a/modules/clothing/_default/client.lua +++ b/modules/clothing/_default/client.lua @@ -4,21 +4,31 @@ Clothing = Clothing or {} ClothingBackup = {} + +---This will set the peds skin data to the specified table. It will also store previous skin in the event it needs returned to original. +---@param data table +---@return boolean Clothing.SetAppearance = function(data) ClothingBackup = Clothing.GetAppearance() Utility.SetEntitySkinData(cache.ped, data) return true end +---This will return a table of the players ped appearance +---@return table Clothing.GetAppearance = function() return Utility.GetEntitySkinData(cache.ped) end +---This will return the peds clothing to the previously stored clothing +---@return boolean Clothing.RestoreAppearance = function() Utility.SetEntitySkinData(cache.ped, ClothingBackup) return true end +---This will reload the peds skin data from the backup table. This is used when the skin data is changed and needs to be reloaded. +---@return boolean Clothing.ReloadSkin = function() Utility.SetEntitySkinData(cache.ped, ClothingBackup) return true diff --git a/modules/dispatch/_default/client/client.lua b/modules/dispatch/_default/client/client.lua index a787258..eeffe67 100644 --- a/modules/dispatch/_default/client/client.lua +++ b/modules/dispatch/_default/client/client.lua @@ -1,5 +1,8 @@ Dispatch = Dispatch or {} +---This will send an alert to currently supported dispatch systems. +---@param data table The data to send to the dispatch system. +---@return nil Dispatch.SendAlert = function(data) TriggerServerEvent('community_bridge:Server:DispatchAlert', { sprite = data.blipData.sprite or 161, diff --git a/modules/dispatch/lb-tablet/client/client.lua b/modules/dispatch/lb-tablet/client/client.lua index 85083ff..83aabee 100644 --- a/modules/dispatch/lb-tablet/client/client.lua +++ b/modules/dispatch/lb-tablet/client/client.lua @@ -13,6 +13,8 @@ local function getPriorityLevel(priority) end end +---commentThis will send an alert to the passed jobs +---@param data table Dispatch.SendAlert = function(data) local streetName, _ = Utility.GetStreetNameAtCoords(data.coords) local priority = getPriorityLevel(data.priority) diff --git a/modules/doorlock/doors_creator/server.lua b/modules/doorlock/doors_creator/server.lua index 0aee303..b9ae565 100644 --- a/modules/doorlock/doors_creator/server.lua +++ b/modules/doorlock/doors_creator/server.lua @@ -2,6 +2,11 @@ if GetResourceState('doors_creator') ~= 'started' then return end Doorlock = Doorlock or {} + +---This will toggle the lock status of the door. +---@param doorID string +---@param toggle boolean +---@return boolean Doorlock.ToggleDoorLock = function(doorID, toggle) local state = toggle if state then diff --git a/modules/doorlock/ox_doorlock/client.lua b/modules/doorlock/ox_doorlock/client.lua index b2dd1aa..3c25dd1 100644 --- a/modules/doorlock/ox_doorlock/client.lua +++ b/modules/doorlock/ox_doorlock/client.lua @@ -2,6 +2,8 @@ if GetResourceState('ox_doorlock') ~= 'started' then return end Doorlock = Doorlock or {} +---This will get the closest door to the ped +---@return string | nil Doorlock.GetClosestDoor = function() return exports.ox_doorlock:getClosestDoor() end diff --git a/modules/framework/qb-core/client.lua b/modules/framework/qb-core/client.lua index ef07efb..e9e9a04 100644 --- a/modules/framework/qb-core/client.lua +++ b/modules/framework/qb-core/client.lua @@ -5,6 +5,8 @@ QBCore = exports['qb-core']:GetCoreObject() Framework = {} +---This will get the name of the framework being used (if a supported framework). +---@return string Framework.GetFrameworkName = function() return 'qb-core' end @@ -13,6 +15,8 @@ Framework.GetPlayerData = function() return QBCore.Functions.GetPlayerData() end +---This will return a table of all the jobs in the framework. +---@return table Framework.GetFrameworkJobs = function() local jobs = {} for k, v in pairs(QBCore.Shared.Jobs) do @@ -25,12 +29,17 @@ Framework.GetFrameworkJobs = function() return jobs end +---This will get the players birth date +---@return string Framework.GetPlayerDob = function() local player = QBCore.Functions.GetPlayerData() local playerData = player.PlayerData return playerData.charinfo.birthdate 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) return QBCore.Functions.GetPlayerData().metadata[metadata] end @@ -61,15 +70,25 @@ Framework.GetItemInfo = function(item) return repackedTable end +---This will get the players identifier (citizenid) etc. +---@return string Framework.GetPlayerIdentifier = function() return QBCore.Functions.GetPlayerData().citizenid end +---This will get the players name (first and last). +---@return string +---@return string Framework.GetPlayerName = function() local playerData = QBCore.Functions.GetPlayerData() return playerData.charinfo.firstname, playerData.charinfo.lastname end +---This will return the players job name, job label, job grade name and job grade level. +---@return string +---@return string +---@return string +---@return string Framework.GetPlayerJob = function() local playerData = QBCore.Functions.GetPlayerData() return playerData.job.name, playerData.job.label, playerData.job.grade.name, playerData.job.grade.level @@ -111,6 +130,8 @@ Framework.GetPlayerInventory = function() return items end +---This will get a players dead status. +---@return boolean Framework.GetIsPlayerDead = function() local playerData = QBCore.Functions.GetPlayerData() return playerData.metadata["isdead"] or playerData.metadata["inlaststand"] diff --git a/modules/framework/qb-core/server.lua b/modules/framework/qb-core/server.lua index 88b1ba1..d72ce64 100644 --- a/modules/framework/qb-core/server.lua +++ b/modules/framework/qb-core/server.lua @@ -32,6 +32,7 @@ end -- Framework.GetPlayerName(src) -- Returns the first and last name of the player. +---@return string, string Framework.GetPlayerName = function(src) local player = QBCore.Functions.GetPlayer(src) if not player then return end @@ -39,6 +40,8 @@ Framework.GetPlayerName = function(src) return playerData.charinfo.firstname, playerData.charinfo.lastname end +---This will get the players birth date +---@return string Framework.GetPlayerDob = function(src) local player = QBCore.Functions.GetPlayer(src) if not player then return end @@ -138,6 +141,7 @@ end -- Framework.SetMetadata(src, metadata, value) -- Adds the specified metadata key and number value to the player's data. +---@return boolean | nil Framework.SetPlayerMetadata = function(src, metadata, value) local player = QBCore.Functions.GetPlayer(src) if not player then return end @@ -156,6 +160,7 @@ end -- Framework.AddStress(src, value) -- Adds the specified value to the player's stress level and updates the client HUD. +---@return number | nil Framework.AddStress = function(src, value) local player = QBCore.Functions.GetPlayer(src) if not player then return end @@ -168,6 +173,7 @@ end -- Framework.RemoveStress(src, value) -- Removes the specified value from the player's stress level and updates the client HUD. +---@return number | nil Framework.RemoveStress = function(src, value) local player = QBCore.Functions.GetPlayer(src) if not player then return end @@ -180,6 +186,7 @@ end -- Framework.AddHunger(src, value) -- Adds the specified value from the player's hunger level. +---@return number | nil Framework.AddHunger = function(src, value) local player = QBCore.Functions.GetPlayer(src) if not player then return end @@ -192,6 +199,7 @@ end -- Framework.AddThirst(src, value) -- Adds the specified value from the player's thirst level. +---@return number | nil Framework.AddThirst = function(src, value) local player = QBCore.Functions.GetPlayer(src) if not player then return end @@ -202,6 +210,9 @@ Framework.AddThirst = function(src, value) return newThirst end +---This will get the hunger of a player +---@param src any +---@return number | nil Framework.GetHunger = function(src) local player = QBCore.Functions.GetPlayer(src) if not player then return end @@ -210,6 +221,10 @@ Framework.GetHunger = function(src) return newHunger end + +---This will get the thirst of a player +---@param src any +---@return number | nil Framework.GetThirst = function(src) local player = QBCore.Functions.GetPlayer(src) if not player then return end @@ -236,8 +251,9 @@ Framework.GetPlayerGang = function(src) return playerData.gang.name end --- Framework.GetPlayersByJob(jobname) --- returns a table of player sources that have the specified job name. +---This will get a table of player sources that have the specified job name. +---@param job any +---@return table Framework.GetPlayersByJob = function(job) local players = QBCore.Functions.GetPlayers() local playerList = {} @@ -250,8 +266,12 @@ Framework.GetPlayersByJob = function(job) return playerList end --- Framework.GetPlayerJob(src) --- Returns the job name, label, grade name, and grade level of the player. +---This will get the players job info +---@param src number +---@return string +---@return string +---@return string +---@return string Framework.GetPlayerJob = function(src) local player = QBCore.Functions.GetPlayer(src) if not player then return end @@ -259,14 +279,21 @@ Framework.GetPlayerJob = function(src) return playerData.job.name, playerData.job.label, playerData.job.grade.name, playerData.job.grade.level end --- Framework.SetPlayerJob(src, name, 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) local player = QBCore.Functions.GetPlayer(src) if not player then return end return player.Functions.SetJob(name, grade) end +---This will toggle a players duty status +---@param src number +---@param status boolean +---@return nil Framework.ToggleDuty = function(src, status) local player = QBCore.Functions.GetPlayer(src) if not player then return end @@ -274,8 +301,12 @@ Framework.ToggleDuty = function(src, status) TriggerEvent('QBCore:Server:SetDuty', src, player.PlayerData.job.onduty) end --- Framework.AddAccountBalance(src, _type, amount) --- Adds the specified amount to the player's account balance of the specified type. + +---This will add money based on the type of account (money/bank) +---@param src number +---@param _type string +---@param amount number +---@return boolean | nil Framework.AddAccountBalance = function(src, _type, amount) local player = QBCore.Functions.GetPlayer(src) if not player then return end @@ -283,8 +314,11 @@ Framework.AddAccountBalance = function(src, _type, amount) return player.Functions.AddMoney(_type, amount) end --- Framework.RemoveAccountBalance(src, _type, amount) --- Removes the specified amount from the player's account balance of the specified type. +---This will remove money based on the type of account (money/bank) +---@param src number +---@param _type string +---@param amount number +---@return boolean | nil Framework.RemoveAccountBalance = function(src, _type, amount) local player = QBCore.Functions.GetPlayer(src) if not player then return end @@ -292,8 +326,10 @@ Framework.RemoveAccountBalance = function(src, _type, amount) return player.Functions.RemoveMoney(_type, amount) end --- Framework.GetAccountBalance(src, _type) --- Returns the player's account balance of the specified type. +---This will remove money based on the type of account (money/bank) +---@param src number +---@param _type string +---@return string | nil Framework.GetAccountBalance = function(src, _type) local player = QBCore.Functions.GetPlayer(src) if not player then return end @@ -341,6 +377,9 @@ Framework.SetMetadata = function(src, item, slot, metadata) return player.Functions.AddItem(item, 1, freeSlot, metadata) end +---This will get all owned vehicles for the player +---@param src number +---@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 .. "'") diff --git a/modules/fuel/_defualts/client.lua b/modules/fuel/_defualts/client.lua index b6213e5..b453052 100644 --- a/modules/fuel/_defualts/client.lua +++ b/modules/fuel/_defualts/client.lua @@ -1,11 +1,18 @@ Fuel = Fuel or {} -----print("Fuel: Loading Defualt") + +---This will get the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@return number fuel The fuel level of the vehicle. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return GetVehicleFuelLevel(vehicle) end -Fuel.SetFuel = function(vehicle, fuel, type) +---This will set the fuel level of the vehicle. +---@param vehicle number The vehicle entity ID. +---@param fuel number The fuel level to set. +---@return nil +Fuel.SetFuel = function(vehicle, fuel) if not DoesEntityExist(vehicle) then return end return SetVehicleFuelLevel(vehicle, fuel) end \ No newline at end of file diff --git a/modules/inventory/ox_inventory/server.lua b/modules/inventory/ox_inventory/server.lua index 5749bcf..e16db1e 100644 --- a/modules/inventory/ox_inventory/server.lua +++ b/modules/inventory/ox_inventory/server.lua @@ -37,7 +37,7 @@ Inventory.GetItem = function(src, item, metadata) return ox_inventory:GetItem(src, item, metadata, false) end ----comment +---This will get the item from the specified slot. ---@param src number ---@param slot number ---@return table @@ -63,14 +63,14 @@ Inventory.HasItem = function(src, item) return count > 0 end ----comment +---This wil return the players inventory. ---@param src number ---@return table Inventory.GetPlayerInventory = function(src) return ox_inventory:GetInventoryItems(src, false) end ----comment +---This is to get if there is available space in the inventory. ---@param src number ---@param item string ---@param count number @@ -79,7 +79,7 @@ Inventory.CanCarryItem = function(src, item, count) return ox_inventory:CanCarryItem(src, item, count) end ----comment +---This will register a stash ---@param id number||string ---@param label string ---@param slots number @@ -106,7 +106,7 @@ Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coo TriggerClientEvent('ox_inventory:openInventory', src, 'stash', 'stash_' .. id) end ----comment +---This will get the data about an item such as name, label, stack, weight, description and image. ---@param item string ---@return table Inventory.GetItemInfo = function(item) @@ -123,7 +123,7 @@ Inventory.GetItemInfo = function(item) return repackedTable end ----comment +---This will set the metadata of an item in the inventory. ---@param src number ---@param item string ---@param slot number @@ -133,7 +133,7 @@ Inventory.SetMetadata = function(src, item, slot, metadata) ox_inventory:SetMetadata(src, slot, metadata) end ----comment +---This will update the plate to the vehicle inside the inventory. (It will also update with jg-mechanic if using it) ---@param oldplate string ---@param newplate string ---@return boolean @@ -144,7 +144,7 @@ Inventory.UpdatePlate = function(oldplate, newplate) return true end ----comment +---This will get the image path for an item, it is an alternate option to GetItemInfo. If a image isnt found will revert to community_bridge logo (useful for menus) ---@param item string ---@return string Inventory.GetImagePath = function(item) diff --git a/modules/vehicleKey/_default/client/client.lua b/modules/vehicleKey/_default/client/client.lua index da6a547..5472dc7 100644 --- a/modules/vehicleKey/_default/client/client.lua +++ b/modules/vehicleKey/_default/client/client.lua @@ -1,9 +1,16 @@ VehicleKey = VehicleKey or {} +---This will give keys to the specifed vehicle/plate. +---@param vehicle number The vehicle entity ID. +---@param plate string The plate of the vehicle. VehicleKey.GiveKeys = function(vehicle, plate) return true, print("There Is No Vehicle Key System Installed") end +---This will remove keys from the specifed vehicle/plate. +---@param vehicle number The vehicle entity ID. +---@param plate string The plate of the vehicle. +---@return boolean | nil VehicleKey.RemoveKeys = function(vehicle, plate) return true, print("There Is No Vehicle Key System Installed") end \ No newline at end of file diff --git a/modules/weather/_default/client.lua b/modules/weather/_default/client.lua index b1d40fe..93a508a 100644 --- a/modules/weather/_default/client.lua +++ b/modules/weather/_default/client.lua @@ -1,7 +1,8 @@ Weather = Weather or {} ----comment +---This will toggle the players weather/time sync ---@param toggle boolean +---@return nil Weather.ToggleSync = function(toggle) end \ No newline at end of file