From 9a26a1b04740ee72a93cbc9daa470299a819741b Mon Sep 17 00:00:00 2001 From: darknight2590 <87971656+darknight2590@users.noreply.github.com> Date: Mon, 20 Dec 2021 10:28:17 +0200 Subject: [PATCH] add GetBoneDistance --- client/functions.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/client/functions.lua b/client/functions.lua index 5ca8d3f..e0a486d 100644 --- a/client/functions.lua +++ b/client/functions.lua @@ -315,6 +315,21 @@ function QBCore.Functions.GetClosestBone(entity, list) return bone, coords, distance end +function QBCore.Functions.GetBoneDistance(entity, Type, Bone) + local bone + + if Type == 1 then + bone = GetPedBoneIndex(entity, Bone) + else + bone = GetEntityBoneIndexByName(entity, Bone) + end + + local boneCoords = GetWorldPositionOfEntityBone(entity, bone) + local playerCoords = GetEntityCoords(PlayerPedId()) + + return #(boneCoords - playerCoords) +end + -- Vehicle function QBCore.Functions.SpawnVehicle(model, cb, coords, isnetworked)