Hello, how would i get vehicles number plate when im facing it?
https://runtime.fivem.net/doc/natives/#_0x377906D8A31E5586
https://runtime.fivem.net/doc/natives/#_0x3D87450E15D98694
https://runtime.fivem.net/doc/natives/#_0x7CE1CCB9B293020E
Have i done something wrong because it doesn’t work
Citizen.CreateThread(function(plate)
local m_key = 244
local pos = GetEntityCoords(PlayerPedId(), true)
local targetPos = GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, 8.0, -1.0)
local StartRay = StartShapeTestRay(pos.x, pos.y, pos.z, targetPos.x, targetPos.y, targetPos.z, 2, PlayerPedId(), 0)
local _,hit,_,_,veh = GetShapeTestResult(StartRay)
local veh = nil
local plate = GetVehicleNumberPlateText(veh)
while true do
Citizen.Wait(1)
if hit and DoesEntityExist(veh) and IsEntityAVehicle(veh) then
currentSelection = veh
if IsControlJustReleased(1, m_key) then
if (not plate) then return end
TriggerEvent('chat:addMessage', {
color = { 255,255,255},
multiline = true,
args = {"Plate: " .. plate}
})
else
currentSelection = nil
end
end
end
end)
This needs to be inside your loop, no?