Add vehicle test for /car command, and use IsModelInCdimage() native

This commit is contained in:
ElPumpo
2019-12-27 14:09:07 +01:00
parent 2d80e55631
commit 756a13f3bb
2 changed files with 13 additions and 7 deletions
+12 -6
View File
@@ -267,13 +267,19 @@ AddEventHandler('esx:setJob', function(job)
end)
RegisterNetEvent('esx:spawnVehicle')
AddEventHandler('esx:spawnVehicle', function(model)
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)
AddEventHandler('esx:spawnVehicle', function(vehicle)
local model = (type(vehicle) == 'number' and vehicle or GetHashKey(vehicle))
ESX.Game.SpawnVehicle(model, coords, 90.0, function(vehicle)
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
end)
if IsModelInCdimage(model) then
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)
ESX.Game.SpawnVehicle(model, coords, 90.0, function(vehicle)
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
end)
else
TriggerEvent('chat:addMessage', { args = { '^1SYSTEM', 'Invalid vehicle model.' } })
end
end)
RegisterNetEvent('esx:pickup')
+1 -1
View File
@@ -1,7 +1,7 @@
function ESX.Streaming.RequestModel(modelHash, cb)
modelHash = (type(modelHash) == 'number' and modelHash or GetHashKey(modelHash))
if not HasModelLoaded(modelHash) then
if not HasModelLoaded(modelHash) and IsModelInCdimage(modelHash) then
RequestModel(modelHash)
while not HasModelLoaded(modelHash) do