mirror of
https://github.com/qbcore-fivem/qb-core.git
synced 2026-08-29 01:08:57 +00:00
Deletes the vehicle if the user is already in it
This commit is contained in:
@@ -50,11 +50,17 @@ end)
|
||||
RegisterNetEvent('QBCore:Command:SpawnVehicle', function(vehName)
|
||||
local ped = PlayerPedId()
|
||||
local hash = GetHashKey(vehName)
|
||||
local veh = GetVehiclePedIsUsing(ped)
|
||||
if not IsModelInCdimage(hash) then return end
|
||||
RequestModel(hash)
|
||||
while not HasModelLoaded(hash) do
|
||||
Wait(0)
|
||||
end
|
||||
|
||||
if IsPedInAnyVehicle(ped) then
|
||||
DeleteVehicle(veh)
|
||||
end
|
||||
|
||||
local vehicle = CreateVehicle(hash, GetEntityCoords(ped), GetEntityHeading(ped), true, false)
|
||||
TaskWarpPedIntoVehicle(ped, vehicle, -1)
|
||||
SetVehicleFuelLevel(vehicle, 100.0)
|
||||
|
||||
Reference in New Issue
Block a user