GetVehiclePlateText: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Removed needs checking, according to mantis this issue is resolved.)
m (→‎Example: Updated the function 'getPlayerOccupiedVehicle)
Line 20: Line 20:
function outputLicensePlate ( command )
function outputLicensePlate ( command )
   -- get the vehicle the local player is in
   -- get the vehicle the local player is in
   local localPlayerOccupiedVehicle = getPlayerOccupiedVehicle ( getLocalPlayer() )
   local localPlayerOccupiedVehicle = getPedOccupiedVehicle ( getLocalPlayer() )
   -- if he is in a vehicle,
   -- if he is in a vehicle,
   if localPlayerOccupiedVehicle then
   if localPlayerOccupiedVehicle then

Revision as of 01:37, 9 September 2012

This function is used to retrieve the text on the number plate of a specified vehicle.

Syntax

string getVehiclePlateText ( vehicle theVehicle )

Required Arguments

  • theVehicle: The vehicle that you wish to retrieve the plate text from.

Returns

Returns a string that corresponds to the plate on the text, false if a bad argument was passed or if the vehicle is not a car.

Example

Click to collapse [-]
Example

This example outputs the text on the license plate of the vehicle the player is driving to the chatbox.

function outputLicensePlate ( command )
  -- get the vehicle the local player is in
  local localPlayerOccupiedVehicle = getPedOccupiedVehicle ( getLocalPlayer() )
  -- if he is in a vehicle,
  if localPlayerOccupiedVehicle then
    -- get the license plate text
    local plateText = getVehiclePlateText ( localPlayerOccupiedVehicle )
    -- if there was a license plate,
    if plateText then
      -- output it to the chatbox
      outputChatBox ( "Your license plate is: " .. plateText )
    else
      outputChatBox ( "Your vehicle has no license plate." )
    end
  else
    outputChatBox ( "You're not in a vehicle." )
  end
end
-- add our function as a handler to the "plate" command
addCommandHandler( "plate", outputLicensePlate )

See Also