GetVehicleOverrideLights: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(OOP)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server client function}}
This function is used to find out the current state of the override-lights setting of a vehicle.
This function is used to find out the current state of the override-lights setting of a vehicle.
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">int getVehicleOverrideLights ( vehicle theVehicle )</syntaxhighlight>
<syntaxhighlight lang="lua">int getVehicleOverrideLights ( vehicle theVehicle )</syntaxhighlight>
 
{{OOP||[[vehicle]]:getOverrideLights|overrideLights|setVehicleOverrideLights}}
===Required Arguments===
===Required Arguments===
*'''theVehicle''': The [[vehicle]] you wish to retrieve the override lights setting of.
*'''theVehicle''': the [[vehicle]] you wish to retrieve the override lights setting of.


==Returns==
===Returns===
Returns an integer value: 0 (No override), 1 (Force off) or 2 (Force on).
Returns an integer value: 0 (No override), 1 (Force off) or 2 (Force on).


Line 13: Line 15:
This example will toggle the car lights on and off for a player's vehicle
This example will toggle the car lights on and off for a player's vehicle
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addCommandHandler ( "vehiclelights", "vehicleLights" )
function vehicleLights ( source )
function vehicleLights ( source )
  vehicle = getPlayerOccupiedVehicle ( source ) -- get the player's vehicle
    local theVehicle = getPlayerOccupiedVehicle ( source )       -- get the player's vehicle
  if ( vehicle ) then -- if he was in one
    if ( theVehicle ) then                                       -- if he was in one
    if ( getVehicleOverrideLights ( vehicle ) ~= 2 ) then -- if the current state isnt 'force on'
        if ( getVehicleOverrideLights ( theVehicle ) ~= 2 ) then -- if the current state isnt 'force on'
      setVehicleOverrideLights ( vehicle, 2 ) -- force the lights on
            setVehicleOverrideLights ( theVehicle, 2 )           -- force the lights on
    else
        else
      setVehicleOverrideLights ( vehicle, 1 ) -- otherwise, force the lights off
            setVehicleOverrideLights ( theVehicle, 1 )           -- otherwise, force the lights off
        end
     end
     end
  end
end
end
addCommandHandler ( "vehiclelights", vehicleLights )
</syntaxhighlight>
</syntaxhighlight>


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

Latest revision as of 16:10, 13 October 2014

This function is used to find out the current state of the override-lights setting of a vehicle.

Syntax

int getVehicleOverrideLights ( vehicle theVehicle )

OOP Syntax Help! I don't understand this!

Method: vehicle:getOverrideLights(...)
Variable: .overrideLights
Counterpart: setVehicleOverrideLights


Required Arguments

  • theVehicle: the vehicle you wish to retrieve the override lights setting of.

Returns

Returns an integer value: 0 (No override), 1 (Force off) or 2 (Force on).

Example

This example will toggle the car lights on and off for a player's vehicle

function vehicleLights ( source )
    local theVehicle = getPlayerOccupiedVehicle ( source )        -- get the player's vehicle
    if ( theVehicle ) then                                        -- if he was in one
        if ( getVehicleOverrideLights ( theVehicle ) ~= 2 ) then  -- if the current state isnt 'force on'
            setVehicleOverrideLights ( theVehicle, 2 )            -- force the lights on
        else
            setVehicleOverrideLights ( theVehicle, 1 )            -- otherwise, force the lights off
        end
    end
end
addCommandHandler ( "vehiclelights", vehicleLights )

See Also