Jump to content

[HELP] Get vehicle by license plate


itsMatheus

Recommended Posts

Is it possible to get a vehicle by its license plate? Like do a command /platecheck [licenseplate] and then return all the information about the vehicle. I'm trying to figure out a way to do it but I can't find a solution. Keep in mind that I am new at scripting, so sorry if this is a easy thing to do.

Link to comment

Maybe you can use this: https://wiki.multitheftauto.com/wiki/GetVehiclePlateText

and if a vehicle with the plate you write is found, show all of the things of that vehicle (idk what you want to show). So something like:

function checkPlate(player, command, text)
	for k, v in ipairs(getElementsByType("vehicle")) do
		if string.lower(getVehiclePlateText(v)) == string.lower(text) then
			outputChatBox("Yey, it worked! Let's output some :~", player, 255, 255, 255, true)
		else
			outputChatBox("fml.", player, 255, 255, 255, true)
		end
	end
end
addCommandHandler("checkplate", checkPlate)

Obviously not tested xD

  • Thanks 1
Link to comment
function getVehicleFromPlate(text)
	local vehicles = getElementsByType('vehicle')
	for i=1,#vehicles do
		if string.lower(getVehiclePlateText(vehicles[i])) == string.lower(text) then
			return vehicles[i]
		end
	end
	return false
end

 

Edited by ShayF
  • Like 1
  • Thanks 1
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...