SetVehicleHeadLightColor: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (Needs example)
Line 20: Line 20:


==Example==  
==Example==  
<section name="Example" class="server" show="true">
<section name="Example" class="both" show="true">
This example changes car color with command ''/carlights red_color, green_color, blue_color''
 
It shows error if player isn't in vehicle or color failed to change. It shows a message if color changed sucessfull.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--TODO
function changeCarLightsColor ( thePlayer, command, red, green, blue )
local vehicle = getPedOccupiedVehicle ( thePlayer )
if ( not vehicle ) then
return outputChatBox( "You don't have vehicle!" )
end
red = tonumber ( red )
green = tonumber ( green )
blue = tonumber ( blue )
-- check if the colour values for red, green and blue are valid
if red and green and blue then
local color = setVehicleHeadLightColor ( vehicle, red, green, blue )
if(not color) then
outputChatBox( "Failed to change vehicle lights color" )
else
outputChatBox ( "Vehicle lights color changed sucessfully" )
end
else
outputChatBox( "Failed to change vehicle lights color" )
end
end
addCommandHandler ( "carlights", changeCarLightsColor )
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>

Revision as of 18:21, 30 July 2009

This function will set the headlight color of a vehicle. valid Red Green and Blue arguments range from 0-255

Syntax

Click to collapse [-]
Server and Client
bool setVehicleHeadLightColor ( vehicle theVehicle, int red, int green, int blue)            

Required Arguments

  • theVehicle: The vehicle that you wish to set the headlight color of.
  • red: An integer indicating the amount of red for the vehicle's headlights
  • green: An integer indicating the amount of green for the vehicle's headlights
  • blue: An integer indicating the amount of blue for the vehicle's headlights

Returns

Returns true if vehicle's headlight color was set, false if an invalid vehicle or invalid color ranges were specified for red,green or blue.

Example

Click to collapse [-]
Example

This example changes car color with command /carlights red_color, green_color, blue_color

It shows error if player isn't in vehicle or color failed to change. It shows a message if color changed sucessfull.

function changeCarLightsColor ( thePlayer, command, red, green, blue )
	local vehicle = getPedOccupiedVehicle ( thePlayer )
	if ( not vehicle ) then
		return outputChatBox( "You don't have vehicle!" )
	end
	red = tonumber ( red )
	green = tonumber ( green )
	blue = tonumber ( blue )
	-- check if the colour values for red, green and blue are valid
	if red and green and blue then
		local color = setVehicleHeadLightColor ( vehicle, red, green, blue )
		if(not color) then
			outputChatBox( "Failed to change vehicle lights color" )
		else
			outputChatBox ( "Vehicle lights color changed sucessfully" )
		end
	else
		outputChatBox( "Failed to change vehicle lights color" )
	end
end
addCommandHandler ( "carlights", changeCarLightsColor )

See Also