Jump to content

Get vehicle element which matches the number plate


callum123

Recommended Posts

function getVehicleByPlate ( plate ) 
    local found = false 
    for _, vehicle in ipairs ( getElementsByType ( "vehicle" ) ) do 
        if ( getVehiclePlateText ( vehicle ) == plate ) then 
            found = vehicle 
            break 
        end 
    end 
  
    return found 
end 

Link to comment
Tried doing this with no luck. Is there some minor tweaks needed? 
  
  
function getVehicleByPlate ( logInDetails ) 
   for _, vehicle in ipairs (getElementsByType ("vehicle")) do 
      if getVehiclePlateText ( vehicle ) == logInDetails  then 
         found = vehicle 
          local x, y, z = getElementPosition(source) 
          local vx, vy, vz = getElementPosition(found) 
             if getDistanceBetweenPoints2D(x, y, vx, vy) < 420 then 
                createBlipAttachedTo(found, 0, 4, 255, 0, 0, 255, 0, 100, source) 
                outputChatBox("Plate registered and found, destination marked on GPS", 255, 0, 0, true) 
             end 
             break 
      end 
      return found 
   end 
end 

Link to comment

Like this will not even display the debug string.

logInDetails1 = "Hello123" 
    for _, vehicle in ipairs (getElementsByType ("vehicle")) do 
        if getVehiclePlateText ( vehicle ) == tostring(logInDetails1)  then 
            outputDebugString("Test") 

Is https://wiki.multitheftauto.com/wiki/GetVehiclePlateText a server function? In the list it is not displayed yet on the actual page it is displayed...?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...