GetVehiclePlateText: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
m (Shortened example var. 'localPlayerOccupiedVehicle' -> 'vehicle')
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Needs Checking|This function doesn't work, mantis #2457 --[[User:Norby89|Norby89]] 13:47, 26 August 2007 (CDT)}}
__NOTOC__
__NOTOC__
{{Server client function}}
{{Server client function}}
Line 20: Line 19:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function outputLicensePlate ( command )
function outputLicensePlate ( command )
  -- get the vehicle the local player is in
    if isPedInVehicle(localPlayer) then --let's check if they're in a vehicle
  local localPlayerOccupiedVehicle = getPlayerOccupiedVehicle ( getLocalPlayer() )
        -- if they are in a vehicle
  -- if he is in a vehicle,
        local vehicle = getPedOccupiedVehicle ( localPlayer ) --let's get the vehicle
  if localPlayerOccupiedVehicle then
        local plateText = getVehiclePlateText ( vehicle ) --get the license plate text
    -- get the license plate text
        if plateText then -- if there was a license plate,
    local plateText = getVehiclePlateText ( localPlayerOccupiedVehicle )
            outputChatBox ( "Your license plate is: " .. plateText )-- output it to the chatbox
    -- if there was a license plate,
        else
    if plateText then
            outputChatBox ( "Your vehicle has no license plate." )
      -- output it to the chatbox
        end
      outputChatBox ( "Your license plate is: " .. plateText )
     else
     else
      outputChatBox ( "Your vehicle has no license plate." )
        outputChatBox ( "You're not in a vehicle." )
     end
     end
  else
    outputChatBox ( "You're not in a vehicle." )
  end
end
end
-- add our function as a handler to the "plate" command
-- add our function as a handler to the "plate" command

Revision as of 20:00, 20 October 2013

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 )
    if isPedInVehicle(localPlayer) then --let's check if they're in a vehicle
         -- if they are in a vehicle
         local vehicle = getPedOccupiedVehicle ( localPlayer ) --let's get the vehicle
         local plateText = getVehiclePlateText ( vehicle ) --get the license plate text
         if plateText then -- if there was a license plate,
             outputChatBox ( "Your license plate is: " .. plateText )-- output it to the chatbox
         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