intelisense stuff
This commit is contained in:
1 parent
e5190cdca0
commit
29d75163a9
13 files changed
+156
-23
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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"]
|
||||
|
||||
@@ -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 .. "'")
|
||||
|
||||
@@ -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
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
Reference in new issue
Block a user