diff --git a/shared/helpers.lua b/shared/helpers.lua index fdd203c..f5c17bc 100644 --- a/shared/helpers.lua +++ b/shared/helpers.lua @@ -56,6 +56,14 @@ function isServer() return IsDuplicityVersion() 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) if not resource or not export then return false end @@ -417,6 +425,7 @@ end function drawLine(startCoords, endCoords, col) if not debugMode then return end + local col = col or vec4(255, 255, 255, 150) CreateThread(function() 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) @@ -435,6 +444,7 @@ end function drawSphere(coords, col) if not debugMode then return end + local col = col or vec4(255, 255, 255, 150) CreateThread(function() for i = 100, 0, -1 do 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)) --- print("Material:", matName) --- ``` -function GetGroundMaterialAtPosition(coords, ped) +function GetGroundMaterialAtPosition(coords, Ped) 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 materialName = "Unknown" for k, v in pairs(materials) do diff --git a/shared/isAnimal.lua b/shared/isAnimal.lua index b19b238..1b9e700 100644 --- a/shared/isAnimal.lua +++ b/shared/isAnimal.lua @@ -73,8 +73,8 @@ if not isServer() then --- local isPlayerAnimal = isAnimal() --- local isSpecificPedAnimal = isAnimal(somePedEntity) --- ``` - function isPedAnimal(ped) - local PedModel = GetEntityModel(ped or PlayerPedId()) + function isPedAnimal(Ped) + local PedModel = GetEntityModel(Ped or PlayerPedId()) for _, animalCategory in pairs(AnimalPeds) do for animalModelHash, _ in pairs(animalCategory) do if PedModel == animalModelHash then @@ -105,8 +105,8 @@ if not isServer() then --- print("Driver is a cat!") --- end --- ``` - function isCat(ped) - local PedModel = GetEntityModel(ped or PlayerPedId()) + function isCat(Ped) + local PedModel = GetEntityModel(Ped or PlayerPedId()) for modelHash, _ in pairs(AnimalPeds.CatPeds) do if PedModel == modelHash then debugPrint("^4isAnimal^7: ^2Ped is ^4Cat") @@ -148,8 +148,8 @@ if not isServer() then --- end --- end --- ``` - function isDog(ped) - local PedModel = GetEntityModel(ped or PlayerPedId()) + function isDog(Ped) + local PedModel = GetEntityModel(Ped or PlayerPedId()) for modelHash, _ in pairs(AnimalPeds.BigDogs) do if PedModel == modelHash then debugPrint("^4isAnimal^7: ^2Ped is ^4Dog") @@ -199,8 +199,8 @@ if not isServer() then --- local getAnim = getAnimalAnims(ped) --- playAnim(getAnim.sitDict, getAnim.sitAnim, -1, 1) --- ``` - function getAnimalAnims(ped) - local model = GetEntityModel(ped) + function getAnimalAnims(Ped) + local model = GetEntityModel(Ped) local animalTable = {} for _, animalCategory in pairs(AnimalPeds) do for k, v in pairs(animalCategory) do @@ -284,4 +284,4 @@ AnimalPeds = { [`a_c_rhesus`] = { deathAnim = "dead", deathDict = "dead_a", exitAnim = "get_up@sat_on_floor@to_stand", exitDict = "getup_0" }, [`ft-capmonkey2`] = { deathAnim = "dead_right", deathDict = "creatures@pug@move", exitAnim = "getup_r", exitDict = "creatures@pug@getup", sitAnim = "base", sitDict = "creatures@pug@amb@world_dog_sitting@base" }, } -} \ No newline at end of file +} diff --git a/shared/notify.lua b/shared/notify.lua index 48770b7..2546952 100644 --- a/shared/notify.lua +++ b/shared/notify.lua @@ -111,7 +111,7 @@ local notifyFunc = { --- triggerNotify("Alert", "You have been warned for misconduct.", "error", playerId) --- ``` 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 notifyFunc[Config.System.Notify].server(title, message, type, src) diff --git a/shared/playerfunctions.lua b/shared/playerfunctions.lua index 8104bb5..95b4461 100644 --- a/shared/playerfunctions.lua +++ b/shared/playerfunctions.lua @@ -236,7 +236,6 @@ local moneyFunc = { --- ```lua --- chargePlayer(100, "cash", playerId) --- ``` ---- function chargePlayer(cost, moneyType, newsrc) local is_success = false local src = newsrc or source