# Anti Duplicate Vehicle

{% tabs %}
{% tab title="server" %}

```lua
local alwaysCheck = false -- if set to false it will only be checked when the vehicle is created, If set to true all vehicles are checked every 5 seconds

if alwaysCheck then
	CreateThread(function()
		while true do
			local plateList = {}
			local allVeh = GetAllVehicles()
			for i=1, #allVeh do
				local plate = GetVehicleNumberPlateText(allVeh[i])
				local model = GetEntityModel(allVeh[i])
				if not plateList[plate] then 
					plateList[plate] = model
				elseif model == plateList[plate] then
					DeleteEntity(allVeh[i])
				end
			end
			Wait(5000)
		end
	end)
else
	AddEventHandler("entityCreating", function(entity, data)
		if GetEntityType(entity) == 2 then
			local myVehiclePlate = GetVehicleNumberPlateText(entity)
			local myVehicleModel = GetEntityModel(entity)
			local allVeh = GetAllVehicles()
			for i=1, #allVeh do
				local veh = allVeh[i]
				if myVehiclePlate == GetVehicleNumberPlateText(veh) and myVehicleModel == GetEntityModel(veh) and entity ~= veh then
					CancelEvent()
					break
				end
			end
		end
	end)
end
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://aklgaming.gitbook.io/documentation/code-snippets/anti-duplicate-vehicle.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
