GetVehiclePlateText: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(OOP)
 
(10 intermediate revisions by 9 users not shown)
Line 1: Line 1:
__NOTOC__
{{Server client function}}
{{Server client function}}
{{Needs Checking|This function doesn't work, mantis #2457 --[[User:Norby89|Norby89]] 13:47, 26 August 2007 (CDT)}}
__NOTOC__
This function is used to retrieve the text on the number plate of a specified vehicle.
This function is used to retrieve the text on the number plate of a specified vehicle.


Line 7: Line 6:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
string getVehiclePlateText ( vehicle theVehicle )
string getVehiclePlateText ( vehicle theVehicle )
</syntaxhighlight>  
</syntaxhighlight>
 
{{OOP||[[vehicle]]:getPlateText|plateText|setVehiclePlateText}}
===Required Arguments===  
===Required Arguments===  
*'''theVehicle:''' A handle to the vehicle that you wish to retrieve the plate text from.
*'''theVehicle:''' the [[vehicle]] that you wish to retrieve the plate text from.


===Returns===
===Returns===
Returns a ''string'' that coresponds to the plate on the text or ''false'' if a bad argument was passed or if the vehicle is not a car.
Returns a ''string'' that corresponds to the plate on the text, ''false'' if a bad argument was passed or if it is not a vehicle. Every vehicle (including planes, boats, etc.) has a numberplate, even if it's not visible.


==Example==  
==Example==  
<section name="Server" class="server" show="true">
<section name="Client" class="client" show="true">
This example outputs the text on the license plate of the vehicle the player is driving to the chatbox.
This example outputs the text on the license plate of the vehicle the player is driving to the chatbox.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function scriptPlate ( player, command )
function outputLicensePlate ( command )
  local aVehicle = getPlayerOccupiedVehicle ( getLocalPlayer() )
    if isPedInVehicle(localPlayer) then --let's check if they're in a vehicle
  local text = getVehiclePlateText ( aVehicle )
        -- if they are in a vehicle
  if ( text and aVehicle ) then
        local vehicle = getPedOccupiedVehicle ( localPlayer ) --let's get the vehicle
    outputChatBox ( "text" )
        local plateText = getVehiclePlateText ( vehicle ) --get the license plate text
  else outputChatBox ( "your vehicle has no licence plate or you're not in a vehicle" )
        if plateText then -- if there was a license plate,
  end
            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
end
addCommandHandler( "plate", scriptPlate )
-- add our function as a handler to the "plate" command
addCommandHandler( "plate", outputLicensePlate )
</syntaxhighlight>
</section>
</section>
</syntaxhighlight>


==See Also==
==See Also==
{{Vehicle functions}}
{{Vehicle functions}}

Latest revision as of 20:33, 13 October 2014

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

Syntax

string getVehiclePlateText ( vehicle theVehicle )

OOP Syntax Help! I don't understand this!

Method: vehicle:getPlateText(...)
Variable: .plateText
Counterpart: setVehiclePlateText


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 it is not a vehicle. Every vehicle (including planes, boats, etc.) has a numberplate, even if it's not visible.

Example

Click to collapse [-]
Client

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