SetVehicleOverrideLights: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 21: Line 21:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function consoleVehicleLights ( source )
function consoleVehicleLights ( source )
     playerVehicle = getPlayerOccupiedVehicle ( source )             -- get the player's vehicle
     playerVehicle = getPedOccupiedVehicle ( source )                 -- get the player's vehicle
     if ( playerVehicle ) then                                        -- if he was in one
     if ( playerVehicle ) then                                        -- if he was in one
         if ( getVehicleOverrideLights ( playerVehicle ) ~= 2 ) then  -- if the current state isn't 'force on'
         if ( getVehicleOverrideLights ( playerVehicle ) ~= 2 ) then  -- if the current state isn't 'force on'
Line 33: Line 33:
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>
<section name="Example 2" class="client" show="false">
<section name="Example 2" class="client" show="true">
This example will toggle the car lights on and off for a player's vehicle by using a "vehiclelights" command.
This example will toggle the car lights on and off for a player's vehicle by using a "vehiclelights" command.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function consoleVehicleLights ()
function consoleVehicleLights ()
     playerVehicle = getPlayerOccupiedVehicle ( getLocalPlayer() )             -- get the local player's vehicle
     playerVehicle = getPedOccupiedVehicle ( getLocalPlayer() )       -- get the local player's vehicle
     if ( playerVehicle ) then                                        -- if he was in one
     if ( playerVehicle ) then                                        -- if he was in one
         if ( getVehicleOverrideLights ( playerVehicle ) ~= 2 ) then  -- if the current state isn't 'force on'
         if ( getVehicleOverrideLights ( playerVehicle ) ~= 2 ) then  -- if the current state isn't 'force on'

Revision as of 15:54, 2 February 2010

This function changes the light overriding setting on a vehicle.

Syntax

bool setVehicleOverrideLights ( vehicle theVehicle, int value )

Required Arguments

  • theVehicle: The vehicle you wish to change the override lights setting of.
  • value: A whole number representing the state of the lights:
    • 0: No override, lights are set to default.
    • 1: Lights are forced off.
    • 2: Lights are forced on.

Returns

Returns true if the vehicle's lights setting was changed. Otherwise false.

Example

Click to collapse [-]
Example 1

This example will toggle the car lights on and off for a player's vehicle by using a "vehiclelights" command.

function consoleVehicleLights ( source )
    playerVehicle = getPedOccupiedVehicle ( source )                 -- get the player's vehicle
    if ( playerVehicle ) then                                        -- if he was in one
        if ( getVehicleOverrideLights ( playerVehicle ) ~= 2 ) then  -- if the current state isn't 'force on'
            setVehicleOverrideLights ( playerVehicle, 2 )            -- force the lights on
        else
            setVehicleOverrideLights ( playerVehicle, 1 )            -- otherwise, force the lights off
        end
    end
end
addCommandHandler ( "vehiclelights", consoleVehicleLights )
Click to collapse [-]
Example 2

This example will toggle the car lights on and off for a player's vehicle by using a "vehiclelights" command.

function consoleVehicleLights ()
    playerVehicle = getPedOccupiedVehicle ( getLocalPlayer() )       -- get the local player's vehicle
    if ( playerVehicle ) then                                        -- if he was in one
        if ( getVehicleOverrideLights ( playerVehicle ) ~= 2 ) then  -- if the current state isn't 'force on'
            setVehicleOverrideLights ( playerVehicle, 2 )            -- force the lights on
        else
            setVehicleOverrideLights ( playerVehicle, 1 )            -- otherwise, force the lights off
        end
    end
end
addCommandHandler ( "vehiclelights", consoleVehicleLights )

See Also