SetVehiclePlateText: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Remove obsolete Requirements section)
 
(13 intermediate revisions by 9 users not shown)
Line 1: Line 1:
__NOTOC__
{{Server client function}}
{{Server client function}}
__NOTOC__
This function can be used to set the numberplate text of a vehicle.
{{New feature/item|3.0140|1.3.3|5394|
All non ascii characters will be replaced by spaces.
This function can be used to change/set the numberplate text from a car.
}}


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
float setVehiclePlateText( element theVehicle, string numberplate )
bool setVehiclePlateText( element theVehicle, string numberplate )
</syntaxhighlight>
</syntaxhighlight>
 
{{OOP||[[vehicle]]:setPlateText|plateText|getVehiclePlateText}}
===Required Arguments===
===Required Arguments===
*'''theVehicle:''' The [[vehicle]] whose numberplate you want to change.
*'''theVehicle:''' the [[vehicle]] whose numberplate you want to change.
*'''numberplate:''' A string that will go on the number plate of the car (max 8 characters).
*'''numberplate:''' a string that will go on the number plate of the vehicle (max 8 characters).


===Returns===
===Returns===
Returns ''true'' if the numberplate was changed successfully, or ''false'' if invalid arguments were passed
Returns ''true'' if the numberplate was changed successfully, or ''false'' if invalid arguments were passed
==Requirements==
{{Requirements|1.3.3|1.3.3|}}


==Example==
==Example==
Line 28: Line 24:
setVehiclePlateText( Vehicle, text )
setVehiclePlateText( Vehicle, text )
else
else
outputChatBox("You must enter a message.",thePlayer)
outputChatBox("You must enter a message or the plate is incorrect.",thePlayer)
end
end
else
else
outputChatBox("You must be a Vehicle.",thePlayer)
outputChatBox("You must be in a Vehicle.",thePlayer)
end
end
end
end

Latest revision as of 17:11, 7 November 2024

This function can be used to set the numberplate text of a vehicle. All non ascii characters will be replaced by spaces.

Syntax

bool setVehiclePlateText( element theVehicle, string numberplate )

OOP Syntax Help! I don't understand this!

Method: vehicle:setPlateText(...)
Variable: .plateText
Counterpart: getVehiclePlateText


Required Arguments

  • theVehicle: the vehicle whose numberplate you want to change.
  • numberplate: a string that will go on the number plate of the vehicle (max 8 characters).

Returns

Returns true if the numberplate was changed successfully, or false if invalid arguments were passed

Example

function PlateText(thePlayer,commandName,text)
	local Vehicle = getPedOccupiedVehicle(thePlayer)
	if Vehicle then
		if text then
			setVehiclePlateText( Vehicle, text )
		else
			outputChatBox("You must enter a message or the plate is incorrect.",thePlayer)
		end
	else
		outputChatBox("You must be in a Vehicle.",thePlayer)
	end
end
addCommandHandler("setplate",PlateText)

See Also