Bit of tidying

This commit is contained in:
Jim Shield
2025-09-10 01:26:02 +01:00
parent 301b069312
commit a0377df713
4 changed files with 22 additions and 13 deletions

View File

@@ -56,6 +56,14 @@ function isServer()
return IsDuplicityVersion() return IsDuplicityVersion()
end end
--- Allows the user to check if an export exists before trying to call it
--- @return boolean boolean True if it exists
---@usage
--- ```lua
--- if checkExportExists("qb-inventory", "OpenInventory") then
--- exports["qb-inventory"]:OpenInventory()
--- end
--- ```
function checkExportExists(resource, export) function checkExportExists(resource, export)
if not resource or not export then return false end if not resource or not export then return false end
@@ -417,6 +425,7 @@ end
function drawLine(startCoords, endCoords, col) function drawLine(startCoords, endCoords, col)
if not debugMode then return end if not debugMode then return end
local col = col or vec4(255, 255, 255, 150)
CreateThread(function() CreateThread(function()
for i = 100, 0, -1 do for i = 100, 0, -1 do
DrawLine(startCoords.x, startCoords.y, startCoords.z, endCoords.x, endCoords.y, endCoords.z, col.x, col.y, col.z, col.w) DrawLine(startCoords.x, startCoords.y, startCoords.z, endCoords.x, endCoords.y, endCoords.z, col.x, col.y, col.z, col.w)
@@ -435,6 +444,7 @@ end
function drawSphere(coords, col) function drawSphere(coords, col)
if not debugMode then return end if not debugMode then return end
local col = col or vec4(255, 255, 255, 150)
CreateThread(function() CreateThread(function()
for i = 100, 0, -1 do for i = 100, 0, -1 do
DrawSphere(coords.x, coords.y, coords.z, 0.5, col.x, col.y, col.z, col.w) DrawSphere(coords.x, coords.y, coords.z, 0.5, col.x, col.y, col.z, col.w)
@@ -875,9 +885,9 @@ local materials = {
--- local matHash, matName = GetGroundMaterialAtPosition(vector3(100,200,300)) --- local matHash, matName = GetGroundMaterialAtPosition(vector3(100,200,300))
--- print("Material:", matName) --- print("Material:", matName)
--- ``` --- ```
function GetGroundMaterialAtPosition(coords, ped) function GetGroundMaterialAtPosition(coords, Ped)
local endCoords = vec3(coords.x, coords.y, coords.z - 1.1) local endCoords = vec3(coords.x, coords.y, coords.z - 1.1)
local rayHandle = StartShapeTestCapsule(coords.x, coords.y, coords.z, endX, endY, endZ, 1.0, 1, Ped or PlayerPedId(), 7) local rayHandle = StartShapeTestCapsule(coords.x, coords.y, coords.z, endCoords.x, endCoords.y, endCoords.z, 1.0, 1, Ped or PlayerPedId(), 7)
local _, hit, _, _, materialHash, _ = GetShapeTestResultIncludingMaterial(rayHandle) local _, hit, _, _, materialHash, _ = GetShapeTestResultIncludingMaterial(rayHandle)
local materialName = "Unknown" local materialName = "Unknown"
for k, v in pairs(materials) do for k, v in pairs(materials) do

View File

@@ -73,8 +73,8 @@ if not isServer() then
--- local isPlayerAnimal = isAnimal() --- local isPlayerAnimal = isAnimal()
--- local isSpecificPedAnimal = isAnimal(somePedEntity) --- local isSpecificPedAnimal = isAnimal(somePedEntity)
--- ``` --- ```
function isPedAnimal(ped) function isPedAnimal(Ped)
local PedModel = GetEntityModel(ped or PlayerPedId()) local PedModel = GetEntityModel(Ped or PlayerPedId())
for _, animalCategory in pairs(AnimalPeds) do for _, animalCategory in pairs(AnimalPeds) do
for animalModelHash, _ in pairs(animalCategory) do for animalModelHash, _ in pairs(animalCategory) do
if PedModel == animalModelHash then if PedModel == animalModelHash then
@@ -105,8 +105,8 @@ if not isServer() then
--- print("Driver is a cat!") --- print("Driver is a cat!")
--- end --- end
--- ``` --- ```
function isCat(ped) function isCat(Ped)
local PedModel = GetEntityModel(ped or PlayerPedId()) local PedModel = GetEntityModel(Ped or PlayerPedId())
for modelHash, _ in pairs(AnimalPeds.CatPeds) do for modelHash, _ in pairs(AnimalPeds.CatPeds) do
if PedModel == modelHash then if PedModel == modelHash then
debugPrint("^4isAnimal^7: ^2Ped is ^4Cat") debugPrint("^4isAnimal^7: ^2Ped is ^4Cat")
@@ -148,8 +148,8 @@ if not isServer() then
--- end --- end
--- end --- end
--- ``` --- ```
function isDog(ped) function isDog(Ped)
local PedModel = GetEntityModel(ped or PlayerPedId()) local PedModel = GetEntityModel(Ped or PlayerPedId())
for modelHash, _ in pairs(AnimalPeds.BigDogs) do for modelHash, _ in pairs(AnimalPeds.BigDogs) do
if PedModel == modelHash then if PedModel == modelHash then
debugPrint("^4isAnimal^7: ^2Ped is ^4Dog") debugPrint("^4isAnimal^7: ^2Ped is ^4Dog")
@@ -199,8 +199,8 @@ if not isServer() then
--- local getAnim = getAnimalAnims(ped) --- local getAnim = getAnimalAnims(ped)
--- playAnim(getAnim.sitDict, getAnim.sitAnim, -1, 1) --- playAnim(getAnim.sitDict, getAnim.sitAnim, -1, 1)
--- ``` --- ```
function getAnimalAnims(ped) function getAnimalAnims(Ped)
local model = GetEntityModel(ped) local model = GetEntityModel(Ped)
local animalTable = {} local animalTable = {}
for _, animalCategory in pairs(AnimalPeds) do for _, animalCategory in pairs(AnimalPeds) do
for k, v in pairs(animalCategory) do for k, v in pairs(animalCategory) do

View File

@@ -111,7 +111,7 @@ local notifyFunc = {
--- triggerNotify("Alert", "You have been warned for misconduct.", "error", playerId) --- triggerNotify("Alert", "You have been warned for misconduct.", "error", playerId)
--- ``` --- ```
function triggerNotify(title, message, type, src) function triggerNotify(title, message, type, src)
if not Config.System or not Config.System.Notify then debugPrint("Notify triggered but not set up") return end if not Config.System?.Notify then debugPrint("Notify triggered but not set up") return end
if src then if src then
notifyFunc[Config.System.Notify].server(title, message, type, src) notifyFunc[Config.System.Notify].server(title, message, type, src)

View File

@@ -236,7 +236,6 @@ local moneyFunc = {
--- ```lua --- ```lua
--- chargePlayer(100, "cash", playerId) --- chargePlayer(100, "cash", playerId)
--- ``` --- ```
---
function chargePlayer(cost, moneyType, newsrc) function chargePlayer(cost, moneyType, newsrc)
local is_success = false local is_success = false
local src = newsrc or source local src = newsrc or source