[Release] Licence Plate Reader (ALPR)

how do i ALPR?
This is how you ALPR!

This Script scans the licence plate in the vehicle infront of you, it has a couple of settings, nothing too interesting.

Keys:

CTRL = Toggle ALPR

Screenies:

http://essentialmo.de/u/bn8ym.png
http://furfag.de/u/x3ohh.png

Credits

Me - for, well, the script
@mraes - for writing the base of the ALPR script and helping me out with raycasts and stuff

Download:
PlateReader.zip (1.2 KB)

Have Fun!

8 Likes

oh no yet another plate checking script :slightly_frowning_face:

1 Like

But it is better than the other scripts, so… :man_shrugging:

1 Like

http://essentialmo.de/u/uyf9q.png
:stuck_out_tongue:

also mine isn’t horribly hacked together,

and can also be easily extended due to it not using horrible coding to make some abstract thing work

Suggestion

You can add a nice nui in the bottom right corner

It seems that for some reason it is not working for me. I added 2 lines of code that basically said if it had started or stopped and that didn’t show up. I also changed the snail thing to a true false because it didn’t show up right in NOTEPAD++. Here is my code:


snail = false

-- you can touch this tho
ScanningDistance = 30.0 -- how far the Plate Reader should look
ControlInputGroup = 27 -- control stuff for changing the key, leave if you don't understand this
ControlKey = 132 -- Default Key is the Control key

-- you shouldn't touch anything under this if you don't understand it


function GetVehicleInfrontOfEntity(entity)
	local coords = GetOffsetFromEntityInWorldCoords(entity,0.0,1.0,0.3)
	local coords2 = GetOffsetFromEntityInWorldCoords(entity, 0.0, ScanningDistance,0.0)
	local rayhandle = CastRayPointToPoint(coords, coords2, 10, entity, 0)
	local _, _, _, _, entityHit = GetRaycastResult(rayhandle)
	if entityHit>0 and IsEntityAVehicle(entityHit) then
		return entityHit
	else
		return nil
	end
end

function RenderVehicleInfo(vehicle)
	local model = GetEntityModel(vehicle)
	local vehname = GetLabelText(GetDisplayNameFromVehicleModel(model))
	local licenseplate = GetVehicleNumberPlateText(vehicle)
	SetTextFont(0)
	SetTextProportional(1)
	SetTextScale(0.0, 0.55)
	SetTextColour(255, 255, 255, 255)
	SetTextDropshadow(0, 0, 0, 0, 255)
	SetTextEdge(1, 0, 0, 0, 255)
	SetTextDropShadow()
	SetTextOutline()
	SetTextEntry("STRING")
	AddTextComponentString("Model: "..vehname.."\nPlate: "..licenseplate)
	DrawText(0.45, 0.9)
end

function RotAnglesToVec(rot) -- input vector3
	local z = math.rad(rot.z)
	local x = math.rad(rot.x)
	local num = math.abs(math.cos(x))
	return vector3(-math.sin(z)*num, math.cos(z)*num, math.sin(x))
end


Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0)
		if DoesEntityExist(GetVehiclePedIsIn(GetPlayerPed(-1))) then
			if snail == true and IsControlJustPressed(ControlInputGroup,ControlKey) then
				snail = false
				TriggerEvent('chatMessage', '', {255,255,255}, '^8ALPR Off')
			elseif snail ~= true and IsControlJustPressed(ControlInputGroup,ControlKey) then
				snail = true
				TriggerEvent('chatMessage', '', {255,255,255}, '^8ALPR On')
			end
			if snail == true then
				local vehicle_detected = GetVehicleInfrontOfEntity(GetVehiclePedIsIn(GetPlayerPed(-1)))
				if DoesEntityExist(vehicle_detected) then
					RenderVehicleInfo(vehicle_detected)
				end
			end
		end
	end
end)

EDIT:

Server Information:

  • Linux Ubuntu 16.04 Server on OVH VPS
  • Latest linux build of FXServer (Just updated before this)
  • FXServer

Probably because you encoded it in ANSI :wink:

and i cannot seem to replicate the issue, i didn’t actually change the :mascot: tho
http://furfag.de/u/817wo.png

I checked the editor I use to script lua (Notepad++) and it was in UTF-8 not ANSI.

I actually finally got mine to work! Everything in it is amazing I just wish that you didn’t have to stare directly at the vehicle for it to show up on screen. I did edit the script some more though:


My Revisions:

  • displaySubtitle is now a separate function
  • Added function displayNotification
  • Added occupant count to ALPR display
  • Fixed height for change of text on ALPR display
  • Now displays when the ALPR is enabled or disabled in Notification

client.lua

snail = "not 🐌" -- don't touch the snail

-- you can touch this tho
ScanningDistance = 30.0 -- how far the Plate Reader should look
ControlInputGroup = 27 -- control stuff for changing the key, leave if you don't understand this
ControlKey = 132 -- Default Key is the Control key

-- you shouldn't touch anything under this if you don't understand it


function GetVehicleInfrontOfEntity(entity)
	local coords = GetOffsetFromEntityInWorldCoords(entity,0.0,1.0,0.3)
	local coords2 = GetOffsetFromEntityInWorldCoords(entity, 0.0, ScanningDistance,0.0)
	local rayhandle = CastRayPointToPoint(coords, coords2, 10, entity, 0)
	local _, _, _, _, entityHit = GetRaycastResult(rayhandle)
	if entityHit>0 and IsEntityAVehicle(entityHit) then
		return entityHit
	else
		return nil
	end
end

function RenderVehicleInfo(vehicle)
	local model = GetEntityModel(vehicle)
	local vehname = GetLabelText(GetDisplayNameFromVehicleModel(model))
	local licenseplate = GetVehicleNumberPlateText(vehicle)
	local passNum = GetVehicleNumberOfPassengers(vehicle)
	if not IsVehicleSeatFree() then
		passNum = passNum + 1
	end
	displaySubtitle("Model: "..vehname.."\nPlate: "..licenseplate.."\nOccupied: "..passNum)
end

function RotAnglesToVec(rot) -- input vector3
	local z = math.rad(rot.z)
	local x = math.rad(rot.x)
	local num = math.abs(math.cos(x))
	return vector3(-math.sin(z)*num, math.cos(z)*num, math.sin(x))
end


Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0)
		if DoesEntityExist(GetVehiclePedIsIn(GetPlayerPed(-1))) then
			if snail == "🐌" and IsControlJustPressed(ControlInputGroup,ControlKey) then
				displayNotification("ALPR ~r~OFF")
				snail = "not 🐌"
			elseif snail ~= "🐌" and IsControlJustPressed(ControlInputGroup,ControlKey) then
				displayNotification("ALPR ~g~ON")
				snail = "🐌"
			end
			if snail == "🐌" then
				local vehicle_detected = GetVehicleInfrontOfEntity(GetVehiclePedIsIn(GetPlayerPed(-1)))
				if DoesEntityExist(vehicle_detected) then
					RenderVehicleInfo(vehicle_detected)
				end
			end
		end
	end
end)

function displaySubtitle(text)
	SetTextFont(0)
	SetTextProportional(1)
	SetTextScale(0.0, 0.55)
	SetTextColour(255, 255, 255, 255)
	SetTextDropshadow(0, 0, 0, 0, 255)
	SetTextEdge(1, 0, 0, 0, 255)
	SetTextDropShadow()
	SetTextOutline()
	SetTextEntry("STRING")
	AddTextComponentString(text)
	DrawText(0.45, 0.88)
end

function displayNotification(text)
	SetNotificationTextEntry("STRING")
	AddTextComponentString(text)
	DrawNotification(false, false)
end
1 Like

Great Stuff! And i know the way that you read plates right now is a bit weird, but i’m too lazy to fix it, maybe later

Honestly I would just increase the delay on the notification going away so that it is more fluid.

I’ve been using this for a few days on my server and its working great, thanks!

2 Likes

Exactly what I’ve been trying to figure out. Really frustrating.

1 Like

What key codes does this script use, because I would like to change the key from control, and I have no idea what the key codes are that it uses?

https://wiki.fivem.net/wiki/Controls

@Bluethefurry Thanks man, you’re great!

yes it is, you would just have to change the script.

1 Like

work with esx ? can you tell me ?

Yes.

Updated screenshots?

1 Like