[HELP] about SetEntityNoCollisionEntity


i want to disable collision for vehicle1 and vehicle2 to all vehicles in city but its only effecting vehicle2

my example code :

vehicle1 = CreateVehicle(GetHashKey('neon'), spawncoords, heading, true, false)
vehicle2 = CreateVehicle(GetHashKey('neon'), spawncoords, heading, true, false)

while true do
    vehs = GetGamePool('CVehicle')
	for _, veh in ipairs(vehs) do
		SetEntityNoCollisionEntity(veh, vehicle1, true)
        SetEntityNoCollisionEntity(veh, vehicle2, true)

i tested many times, its only effecting vehicle2 unless i remove the SetEntityNoCollisionEntity for vehicle2 but i want to do it for both

any suggestion ?

1 Like


You mispelled vehicle1 in SetEntityNoCollisionEntity

You’ve set SetEntityNoCollisionEntity(veh, vehicle, true)
Instead of SetEntityNoCollisionEntity(veh, vehicle1, true)

I wrote it here wrong but on my server the coding is right and not working on both vehicles

but I found another method :


the different is this method is better with better resmon (using it with a loop)
the only thing that was gone was visibility of the entity but since i could not fix SetEntityNoCollisionEntity i guess its the only choice here