From f62b2f31b4bd2c4af39b11da67aa88c4e1347e93 Mon Sep 17 00:00:00 2001 From: darknight2590 <87971656+darknight2590@users.noreply.github.com> Date: Sat, 25 Dec 2021 12:47:04 +0200 Subject: [PATCH] attachProp function --- client/functions.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/client/functions.lua b/client/functions.lua index 67919f2..7d26c36 100644 --- a/client/functions.lua +++ b/client/functions.lua @@ -362,6 +362,19 @@ function QBCore.Functions.GetBoneDistance(entity, Type, Bone) return #(boneCoords - playerCoords) end +function QBCore.Functions.attachProp(ped, model, boneId, x, y, z, xR, yR, zR, Vertex) + local modelHash = GetHashKey(model) + local bone = GetPedBoneIndex(ped, boneId) + RequestModel(modelHash) + while not HasModelLoaded(modelHash) do + Wait(0) + end + local prop = CreateObject(modelHash, 1.0, 1.0, 1.0, 1, 1, 0) + AttachEntityToEntity(prop, ped, bone, x, y, z, xR, yR, zR, 1, 1, 0, 1, not Vertex and 2 or 0, 1) + SetModelAsNoLongerNeeded(modelHash) + return prop +end + -- Vehicle function QBCore.Functions.SpawnVehicle(model, cb, coords, isnetworked)