From 3b36f7e4e5903e0ddd2ef90df219caf34f51d27c Mon Sep 17 00:00:00 2001 From: Liam Dormon <66041893+Mojito-Fivem@users.noreply.github.com> Date: Sat, 19 Feb 2022 06:39:50 +0000 Subject: [PATCH] fix(client/functions): type checking for vectors (#430) allows for cross scrt compatibility with newer functions --- client/functions.lua | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/client/functions.lua b/client/functions.lua index 87a5887..fd6a967 100644 --- a/client/functions.lua +++ b/client/functions.lua @@ -62,17 +62,19 @@ function QBCore.Functions.CreateBlip(coords, sprite, display, scale, colour, sho if not coords or not sprite or not display or not scale or not colour or shortRange == nil or not title then print("Blip failed to create, most likely missed a setting, debug log: ") print("Coords: " .. coords .. " Sprite: " .. sprite .. " Display: " .. display .. " scale: " .. scale .. " shortRange: " .. shortRange .. " Title: " .. title .. " if you're attempting to use a blip without a title, use an empty string.") - else - blip = AddBlipForCoord(coords) - SetBlipSprite(blip, sprite) - SetBlipDisplay(blip, display) - SetBlipScale(blip, scale) - SetBlipColour(blip, colour) - SetBlipAsShortRange(blip, shortRange) - BeginTextCommandSetBlipName("STRING") - AddTextComponentString(title) - EndTextCommandSetBlipName(blip) + return end + + coords = type(coords) == 'table' and vec3(coords.x, coords.y, coords.z) or coords + blip = AddBlipForCoord(coords) + SetBlipSprite(blip, sprite) + SetBlipDisplay(blip, display) + SetBlipScale(blip, scale) + SetBlipColour(blip, colour) + SetBlipAsShortRange(blip, shortRange) + BeginTextCommandSetBlipName("STRING") + AddTextComponentString(title) + EndTextCommandSetBlipName(blip) end function QBCore.Functions.RequestAnimDict(animDict) @@ -403,6 +405,11 @@ function QBCore.Functions.GetPlate(vehicle) end function QBCore.Functions.SpawnClear(coords, radius) + if coords then + coords = type(coords) == 'table' and vec3(coords.x, coords.y, coords.z) or coords + else + coords = GetEntityCoords(ped) + end local vehicles = GetGamePool('CVehicle') local closeVeh = {} for i=1, #vehicles, 1 do