From 987a40bf0d92f5a196fa30654d020b74fe4744cd Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Sat, 5 May 2018 23:56:12 +0200 Subject: [PATCH] ESX.Game.GetVehicleInDirection, no more car spawn with radio --- client/functions.lua | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/client/functions.lua b/client/functions.lua index 0aa4aa40..510e3454 100644 --- a/client/functions.lua +++ b/client/functions.lua @@ -390,7 +390,6 @@ ESX.Game.SpawnVehicle = function(modelName, coords, heading, cb) local id = NetworkGetNetworkIdFromEntity(vehicle) SetNetworkIdCanMigrate(id, true) - --SetEntityAsMissionEntity(vehicle, true, false) SetVehicleHasBeenOwnedByPlayer(vehicle, true) SetModelAsNoLongerNeeded(model) @@ -401,6 +400,8 @@ ESX.Game.SpawnVehicle = function(modelName, coords, heading, cb) Citizen.Wait(0) end + SetVehRadioStation(vehicle, 'OFF') + if cb ~= nil then cb(vehicle) end @@ -423,7 +424,6 @@ ESX.Game.SpawnLocalVehicle = function(modelName, coords, heading, cb) local vehicle = CreateVehicle(model, coords.x, coords.y, coords.z, heading, false, false) - --SetEntityAsMissionEntity(vehicle, true, false) SetVehicleHasBeenOwnedByPlayer(vehicle, true) SetModelAsNoLongerNeeded(model) @@ -434,6 +434,8 @@ ESX.Game.SpawnLocalVehicle = function(modelName, coords, heading, cb) Citizen.Wait(0) end + SetVehRadioStation(vehicle, 'OFF') + if cb ~= nil then cb(vehicle) end @@ -642,6 +644,16 @@ ESX.Game.GetVehiclesInArea = function(coords, area) return vehiclesInArea end +ESX.Game.GetVehicleInDirection = function() + local playerPed = GetPlayerPed(-1) + local playerCoords = GetEntityCoords(playerPed, 1) + local inDirection = GetOffsetFromEntityInWorldCoords(playerPed, 0.0, 5.0, 0.0) + local rayHandle = CastRayPointToPoint(playerCoords.x, playerCoords.y, playerCoords.z, inDirection.x, inDirection.y, inDirection.z, 10, playerPed, 0) + local a, b, c, d, vehicle = GetRaycastResult(rayHandle) + + return vehicle +end + ESX.Game.GetPeds = function(ignoreList) local ignoreList = ignoreList or {}