GetVehicleVariant: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 4: Line 4:
Only available in MTA:SA v1.2 and onwards.
Only available in MTA:SA v1.2 and onwards.
}}
}}
Page in the making.
This function gets the variant of a specified vehicle. In GTA SA some vehicles are different for example the labelling on trucks or the contents of a pick-up truck and the varying types of a motor bike. For the default GTA SA variant list see: [[Vehicle variants]]


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">int getVehicleLightState ( vehicle theVehicle, int light )</syntaxhighlight>
<syntaxhighlight lang="lua">int, int getVehicleVariant ( vehicle theVehicle )</syntaxhighlight>


==Required Arguments==
==Required Arguments==
*'''theVehicle:''' A handle to the [[vehicle]] that you wish to know the light state of.
*'''theVehicle:''' A handle to the [[vehicle]] that you want to get the variant of.
*'''light:''' A whole number between 0 and 3


==Returns==
==Returns==
Returns 0 (working) or 1 (broken)
On success:
* '''int''': An integer for the first vehicle variant see [[Vehicle variants]]
* '''int''': An integer for the second vehicle variant see [[Vehicle variants]]
On failure:
* '''bool''': False because the specified vehicle didn't exist


==Example==
==Example==
<syntaxhighlight lang="lua">newcar = createVehicle ( 520, 1024, 1024, 1024 )
<section name="Client" class="client" show="true">
state = getVehicleLightState ( newcar, 0 )
This example tells the person in the vehicle what their vehicle variants are using: getvehvar
outputChatBox ( "The front-left light state on this car: " .. state )</syntaxhighlight>
<syntaxhighlight lang="lua">
function getMyVehiclesVariant()
    local myVeh = getPedOccupiedVehicle(localPlayer) -- Get the vehicle that they're in
    if (myVeh) then
        local var1, var2 = getVehicleVariant(myVeh) -- Get the info
        outputChatBox("This vehicles variants: "..tostring(var1).." "..tostring(var2)) -- Output the info
    end
end
addCommandHandler("getvehvar", getMyVehiclesVariant)
</syntaxhighlight>
</section>


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

Revision as of 23:33, 16 November 2011

Only available in MTA:SA v1.2 and onwards. This function gets the variant of a specified vehicle. In GTA SA some vehicles are different for example the labelling on trucks or the contents of a pick-up truck and the varying types of a motor bike. For the default GTA SA variant list see: Vehicle variants

Syntax

int, int getVehicleVariant ( vehicle theVehicle )

Required Arguments

  • theVehicle: A handle to the vehicle that you want to get the variant of.

Returns

On success:

On failure:

  • bool: False because the specified vehicle didn't exist

Example

Click to collapse [-]
Client

This example tells the person in the vehicle what their vehicle variants are using: getvehvar

function getMyVehiclesVariant()
    local myVeh = getPedOccupiedVehicle(localPlayer) -- Get the vehicle that they're in
    if (myVeh) then
        local var1, var2 = getVehicleVariant(myVeh) -- Get the info
        outputChatBox("This vehicles variants: "..tostring(var1).." "..tostring(var2)) -- Output the info
    end
end
addCommandHandler("getvehvar", getMyVehiclesVariant)

See Also