[RELEASE] Police ALPR

Works very well for me…


This may be a dumb question but does this work for civ as in not just AI?

The ALPR detects player and AI vehicles. Not really sure what you mean- but in order to use the ALPR it requires the player to be in a police vehicle.

1 Like

Leaving this here as it has been awhile- added some changes of my own:

local radarEnabled = false
local froze = false
Citizen.CreateThread( function()
	while true do
		Wait(0)
		if IsControlJustPressed(1, 128) and IsPedInAnyPoliceVehicle(GetPlayerPed(-1)) then
			radarEnabled = true
			if radar.shown then 
				radar.shown = false 
				radar.info = string.format("~y~Initializing ALPR...~w~321...~y~Loaded! ")
				radar.info2 = string.format("~y~Initializing ALPR...~w~321...~y~Loaded! ")
			else 
				radar.shown = true 
			end		
                Wait(75)
		end
		if IsControlJustPressed(1, 127) and IsPedInAnyPoliceVehicle(GetPlayerPed(-1)) then
			if radar.freeze then radar.freeze = false else radar.freeze = true end
		end
		if radar.shown  then
			if radar.freeze == false then
					DrawAdvancedText(0.521, 0.903, 0.005, 0.0028, 0.4, "~g~Active", 0, 191, 255, 255, 6, 0)
					local veh = GetVehiclePedIsIn(GetPlayerPed(-1), false)
					local coordA = GetOffsetFromEntityInWorldCoords(veh, 0.0, 1.0, 1.0)
					local coordB = GetOffsetFromEntityInWorldCoords(veh, 0.0, 105.0, 0.0)
					local frontcar = StartShapeTestCapsule(coordA, coordB, 3.0, 10, veh, 7)
					local a, b, c, d, e = GetShapeTestResult(frontcar)
					if IsEntityAVehicle(e) then
						local fmodel = GetDisplayNameFromVehicleModel(GetEntityModel(e))
						local fvspeed = GetEntitySpeed(e)*2.236936
						local fplate = GetVehicleNumberPlateText(e)
						radar.info = string.format("~y~Plate: ~w~%s  ~y~Model: ~w~%s  ~y~Speed: ~w~%s mph", fplate, fmodel, math.ceil(fvspeed))
					end
					local bcoordB = GetOffsetFromEntityInWorldCoords(veh, 0.0, -105.0, 0.0)
					local rearcar = StartShapeTestCapsule(coordA, bcoordB, 3.0, 10, veh, 7)
					local f, g, h, i, j = GetShapeTestResult(rearcar)
					if IsEntityAVehicle(j) then
		
						local bmodel = GetDisplayNameFromVehicleModel(GetEntityModel(j))
						local bvspeed = GetEntitySpeed(j)*2.236936
						local bplate = GetVehicleNumberPlateText(j)
						radar.info2 = string.format("~y~Plate: ~w~%s  ~y~Model: ~w~%s  ~y~Speed: ~w~%s mph", bplate, bmodel, math.ceil(bvspeed))
					end
				else
					DrawAdvancedText(0.521, 0.903, 0.005, 0.0028, 0.4, "~r~Froze", 0, 191, 255, 255, 6, 0)	
			end
			DrawRect(0.508, 0.94, 0.196, 0.116, 0, 0, 0, 150)
			DrawAdvancedText(0.591, 0.903, 0.005, 0.0028, 0.4, "Front Radar", 0, 191, 255, 255, 6, 0)
			DrawAdvancedText(0.591, 0.953, 0.005, 0.0028, 0.4, "Rear Radar", 0, 191, 255, 255, 6, 0)
			DrawAdvancedText(0.6, 0.928, 0.005, 0.0028, 0.4, radar.info, 255, 255, 255, 255, 6, 0)
			DrawAdvancedText(0.6, 0.979, 0.005, 0.0028, 0.4, radar.info2, 255, 255, 255, 255, 6, 0)	
		end
		if(not IsPedInAnyVehicle(GetPlayerPed(-1))) then 
			radar.shown = false
		elseif radarEnabled and IsPedInAnyPoliceVehicle(GetPlayerPed(-1)) then
			radar.shown = true
		end				
	end
end)
  • Added text in the top-left corner indicating the status of the ALPR.
  • ALPR retains information upon exiting a vehicle and returning to it.

alpr

Idk how this could be done but ive tried to do
If local fmodel = IsVehicleModel(193895207) ---- firetruk
then
radar.info = string.format("~b~Plate: ~w~%s ~b~Model: ~r~%s ~b~Speed: ~w~%s mph", fplate, fmodel, math.ceil(fvspeed))

and the model colour goes red but sadly it wont work does anyone know a way to do this

Can you maybe sent me your versions? I need a way to change the keybinds haha.

That comment was from 2017. I don’t use this anymore and don’t have those files. Sorry I couldn’t help you.

I’m trying to make some modifications so only players with job “police” and in any vehicle they can use the radar because in my server police use add-on vehicles:

ESX = nil

Citizen.CreateThread(function()
	while ESX == nil do
		TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
		Citizen.Wait(0)
	end

	while ESX.GetPlayerData().job == nil do
		Citizen.Wait(10)
	end

	ESX.PlayerData = ESX.GetPlayerData()
end)

RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer)
	ESX.PlayerData = xPlayer
end)

RegisterNetEvent('esx:setJob')
AddEventHandler('esx:setJob', function(job)
	ESX.PlayerData.job = job
end)

local radar =
{
	shown = false,
	freeze = false,
	info = "~y~Iniciando RADAR...~w~321...~y~Listo! ",
	info2 = "~y~Iniciando RADAR...~w~321...~y~Listo! ",
	minSpeed = 5.0,
	maxSpeed = 75.0,
}

function DrawAdvancedText(x,y ,w,h,sc, text, r,g,b,a,font,jus)
    SetTextFont(font)
    SetTextProportional(0)
    SetTextScale(sc, sc)
	N_0x4e096588b13ffeca(jus)
    SetTextColour(r, g, b, a)
    SetTextDropShadow(0, 0, 0, 0,255)
    SetTextEdge(1, 0, 0, 0, 255)
    SetTextDropShadow()
    SetTextOutline()
    SetTextEntry("STRING")
    AddTextComponentString(text)
	DrawText(x - 0.1+w, y - 0.02+h)
end

function UpdateRadar()
	DrawRect(0.508, 0.94, 0.196, 0.116, 0, 0, 0, 150)
	DrawAdvancedText(0.591, 0.903, 0.005, 0.0028, 0.4, "Radar delantero", 0, 191, 255, 255, 6, 0)
	DrawAdvancedText(0.591, 0.953, 0.005, 0.0028, 0.4, "Radar trasero", 0, 191, 255, 255, 6, 0)
	DrawAdvancedText(0.6, 0.928, 0.005, 0.0028, 0.4, radar.info, 255, 255, 255, 255, 6, 0)
	DrawAdvancedText(0.6, 0.979, 0.005, 0.0028, 0.4, radar.info2, 255, 255, 255, 255, 6, 0)	
end

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0)

		if ESX.PlayerData.job then
			Citizen.Wait(0)
			
			if IsControlJustReleased(1, 128) and IsPedInAnyVehicle(GetPlayerPed(-1)) and ESX.PlayerData.job.name == 'police' then				
				if radar.shown then 
					radar.shown = false 
					radar.info = string.format("~y~Iniciando RADAR...~w~321...~y~Listo! ")
					radar.info2 = string.format("~y~Iniciando RADAR...~w~321...~y~Listo! ")
				else 
					radar.shown = true 
				end		
				
				--Citizen.Wait(75)				
			end
			
			if IsControlJustReleased(1, 127) and IsPedInAnyVehicle(GetPlayerPed(-1)) and ESX.PlayerData.job == 'police' then			
				if radar.freeze then 
					radar.freeze = false 
				else 
					radar.freeze = true 
				end		
			end
			
			if radar.shown then
				if radar.freeze == false then
					local veh = GetVehiclePedIsIn(GetPlayerPed(-1), false)
					local coordA = GetOffsetFromEntityInWorldCoords(veh, 0.0, 1.0, 1.0)
					local coordB = GetOffsetFromEntityInWorldCoords(veh, 0.0, 105.0, 0.0)
					local frontcar = StartShapeTestCapsule(coordA, coordB, 3.0, 10, veh, 7)
					local a, b, c, d, e = GetShapeTestResult(frontcar)
					
					if IsEntityAVehicle(e) then						
						local fmodel = GetDisplayNameFromVehicleModel(GetEntityModel(e))
						local fvspeed = GetEntitySpeed(e)--*2.236936
						local fplate = GetVehicleNumberPlateText(e)
						radar.info = string.format("~y~Matrícula: ~w~%s  ~y~Modelo: ~w~%s  ~y~Velocidad: ~w~%s km/h", fplate, fmodel, math.ceil(fvspeed))
						UpdateRadar()
					end
					
					local bcoordB = GetOffsetFromEntityInWorldCoords(veh, 0.0, -105.0, 0.0)
					local rearcar = StartShapeTestCapsule(coordA, bcoordB, 3.0, 10, veh, 7)
					local f, g, h, i, j = GetShapeTestResult(rearcar)
					
					if IsEntityAVehicle(j) then					
						local bmodel = GetDisplayNameFromVehicleModel(GetEntityModel(j))
						local bvspeed = GetEntitySpeed(j)--*2.236936
						local bplate = GetVehicleNumberPlateText(j)
						radar.info2 = string.format("~y~Matrícula: ~w~%s  ~y~Modelo: ~w~%s  ~y~Velocidad: ~w~%s km/h", bplate, bmodel, math.ceil(bvspeed))
						UpdateRadar()						
					end
				end							
			end
			
			if(not IsPedInAnyVehicle(GetPlayerPed(-1))) then
				radar.shown = false
				radar.info = string.format("~y~Iniciando RADAR...~w~321...~y~Listo! ")
				radar.info2 = string.format("~y~Iniciando RADAR...~w~321...~y~Listo! ")
			end
			
			Citizen.Wait(500)
		end
	end
end)

The problem is that the radar is blinking, it’s not static it’s showing for very little time (maybe 0,5 secs) then it disappears…

Here’s an example of what I’m trying to say:

How cann i change to km/h?

did you fix this?

hello how can I change the radar place for example leave it up and not down as it comes by default

did you get any answer on how to change position?

hello how can I change the radar place for example leave it up and not down as it comes by defaultt

Can you elaborate? I’m unsure if you are referring to changing the placement of the UI or are having problems with the display staying up.

I need to move the location of the interface above it bothers me where it is for the speedometer and I don’t know how to do it, I don’t know what strings to put, if you help me I thank you very much

Do the painful process of changing the coordinates of the UI in the DrawAdvancedText lines.

Or change your speedometer.

Glhf.

which car hud you use?

Hi guys i need help about the script , i wanna make a command for this script wich display the vehicle plate in the radar. Is something like this /plate and the command would work with the vehicle plate displayed at the moment in the radar and put the info in the server chat. But i dont have idea how to do it.

Hello this is what key to put the radar on our police vehicle ?

How can I move the position of the radar?