From 1228c942cf81f7fa2075830bcd647a8b6eab581e Mon Sep 17 00:00:00 2001 From: Frowmza <66181451+Frowmza@users.noreply.github.com> Date: Sun, 29 Dec 2024 18:36:50 +0100 Subject: [PATCH 1/2] fix(lib/spawn): get vehicle type on client --- modules/lib.lua | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/modules/lib.lua b/modules/lib.lua index 8706bdc87..a6a7f64b5 100644 --- a/modules/lib.lua +++ b/modules/lib.lua @@ -265,15 +265,7 @@ if isServer then coords = vec4(pedCoords.x, pedCoords.y, pedCoords.z, GetEntityHeading(source)) end - local vehicleType = exports.qbx_core:GetVehiclesByHash(model).type - if not vehicleType then - local tempVehicle = CreateVehicle(model, 0, 0, -200, 0, true, true) - while not DoesEntityExist(tempVehicle) do Wait(0) end - - vehicleType = GetVehicleType(tempVehicle) - DeleteEntity(tempVehicle) - end - + local vehicleType = exports.qbx_core:GetVehiclesByHash(model)?.type or lib.callback.await('qbx_core:client:getVehicleType', math.random(#GetPlayers()), model) local attempts = 0 local veh, netId From abea0fc91c1b26aa7f4c01cf81a9dcff592654c4 Mon Sep 17 00:00:00 2001 From: Frowmza <66181451+Frowmza@users.noreply.github.com> Date: Sun, 29 Dec 2024 18:38:48 +0100 Subject: [PATCH 2/2] fix(lib/spawn): callback handle --- modules/lib.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/lib.lua b/modules/lib.lua index a6a7f64b5..afc041611 100644 --- a/modules/lib.lua +++ b/modules/lib.lua @@ -339,6 +339,18 @@ if isServer then return netId, veh end else + ---@param model number|string + ---@return string + lib.callback.register('qbx_core:client:getVehicleType', function(model) + model = lib.requestModel(model) + local coords = GetEntityCoords(cache.ped) + local tempVehicle = CreateVehicle(model, coords.x, coords.y, coords.z - 20.0, 0, false, false) + SetModelAsNoLongerNeeded(model) + local type = GetVehicleType(tempVehicle) + DeleteEntity(tempVehicle) + return type + end) + ---@class LibDrawTextParams ---@field text string ---@field scale? integer default: `0.35`