Jump to content

Get vehicle element which matches the number plate


callum123

Recommended Posts

Posted

How do I get the vehicle from the number plate? Is it possible? I want to add a blip to the vehicle without anyone inside it. I want to get hold of the vehicle from the number plate....

Posted
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 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
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 

Posted

Any errors on debugscript?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

No errors no, even if I do

      if getVehiclePlateText ( vehicle ) == "Hello123"  then 

And I know there is a vehicle with that plate, it seems not to enter the if statement.

Posted

Try looping all vehicles and get their plate text.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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...?

Posted

I did a simple test, created random vehicle get the plate text, and returns wrong one. I guess this function doesn't work so good.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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...