[HELP] How to lock NPC vehicles?

Hello there, I want to make players can not enter NPC vehicles, how to do so?

This would stop a player from trying to steal a car from an NPC.

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0)
		if GetVehiclePedIsTryingToEnter(GetPlayerPed(-1)) ~= 0 then
			local vehicle = GetVehiclePedIsTryingToEnter(GetPlayerPed(-1))
			if GetPedInVehicleSeat(vehicle, -1) ~= 0 then
				if not IsPedAPlayer(GetPedInVehicleSeat(vehicle, -1)) and not IsPedDeadOrDying(GetPedInVehicleSeat(vehicle, -1)) then
					Wait(500)
					local playerPos = GetEntityCoords(GetPlayerPed(-1), true)
					SetEntityCoords(GetPlayerPed(-1), playerPos.x, playerPos.y, playerPos.z - 1)
				end
			end
		end
	end
end)
1 Like

How do i add that as a resource?

create a client.lua and take this script there in.
but it stopped only steeling von NPC Vehicle where a NPC is inside, not parked NPC Cars