BlacklistedModels = {
-- peds
[`csb_mweather`] = true,
[`a_m_m_hillbilly_02`] = true,
}
RegisterNetEvent('entityCreating')
AddEventHandler('entityCreating', function(entity)
local model = GetEntityModel(entity)
if not BlacklistedModels[model] then return end
CancelEvent()
end)
In the example above, where an entity of a_m_m_hillbilly_02 is about to be created, they are spawned on a Sanchez around mid-town Los Santos. This will stop the hillbilly from being created, but leave the sanchez behind.
You can replicate this very easily by using some random peds and driving down the highway, seeing ghost cars driving in to walls and stuff because their driver wasn’t created, but the car (and sometimes passenger) were.
Not sure if this can be considered a bug, peds are only created for population vehicles way after the vehicles are created, so there is no “correct” behavior for this that should be considered a default and not handled by user script.
Can’t you get the vehicle the ped is in and delete that manually when rejecting?
I wasn’t sure if it was a bug either but it was working fine on previous server builds.
I believe doing a manual vehicle check and deleting that vehicle will do the trick. The thing to consider here would be passengers being created for those vehicles too. Would it be possible that we delete the vehicle before the passenger is created, which would leave a stranded ped?
That still won’t behave correctly as a pretend occupant would.
What problem are you trying to solve here? I think it’d be better solved by, say, loading a DLC_POP_GROUPS file to suppress the model you want to not have part of ambient non-scenario population.
Hi, here is a solution where you scan the vehicle based on the created ped and then delete vehicle and the ped.
Although if more ped are created in the vehicle, unfortunately only the client side use native (GetPedInVehicleSeat ()).
BlacklistedModels = {
-- peds
[`csb_mweather`] = true,
[`a_m_m_hillbilly_02`] = true,
}
RegisterNetEvent('entityCreating')
AddEventHandler('entityCreating', function(entity)
local model = GetEntityModel(entity)
if not BlacklistedModels[model] then return end
Citizen.Wait(100) -- I don't know necessary (unfortunately I can't test since I'm banned, although I don't know why.)
local vehicle = GetVehiclePedIsIn(entity, false)
DeleteEntity(vehicle)
DeleteEntity(entity)
--CancelEvent()
end)