mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 17:28:53 +00:00
Add vehicle test for /car command, and use IsModelInCdimage() native
This commit is contained in:
+12
-6
@@ -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,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
|
||||
|
||||
Reference in New Issue
Block a user