GetVehicleVariant: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "{{Server client function}} __NOTOC__ Page in the making. ==Syntax== <syntaxhighlight lang="lua">int getVehicleLightState ( vehicle theVehicle, int light )</syntaxhighlight> ==Required Arguments== *'''th...")
 
(Remove obsolete Requirements section)
 
(7 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{Server client function}}
{{Shared function}}
__NOTOC__
__NOTOC__
Page in the making.
This function gets the variant of a specified vehicle. In GTA: San Andreas 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 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>
{{OOP||[[vehicle]]:getVariant||setVehicleVariant}}


==Required Arguments==
===Required Arguments===
*'''theVehicle:''' A handle to the [[vehicle]] that you wish to know the light state of.
*'''theVehicle:''' 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)
Returns 2 [[int]] containing the vehicle variants, ''false'' otherwise (the specified vehicle doesn't exist).


==Example==
==Example==
<syntaxhighlight lang="lua">newcar = createVehicle ( 520, 1024, 1024, 1024 )
<section name="Client example" class="client" show="true">
state = getVehicleLightState ( newcar, 0 )
This example tells the [[player]] in the [[vehicle]] what their vehicle variants are with a command named ''getvehvar'':
outputChatBox ( "The front-left light state on this car: " .. state )</syntaxhighlight>
<syntaxhighlight lang="lua">
function getMyVehicleVariants()
    local myVeh = getPedOccupiedVehicle(localPlayer) -- Get the vehicle that the player is in
 
    if myVeh then
        local variant1, variant2 = getVehicleVariant (myVeh) -- Get the vehicle variants
 
        outputChatBox ("This vehicle's variants are: "..tostring (variant1).." "..tostring (variant2)) -- Output the info to chatbox
    end
end
 
addCommandHandler ("getvehvar", getMyVehicleVariants)
</syntaxhighlight>
 
</section>


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

Latest revision as of 15:35, 7 November 2024

This function gets the variant of a specified vehicle. In GTA: San Andreas 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 variant list see: Vehicle variants.

Syntax

int, int getVehicleVariant ( vehicle theVehicle )

OOP Syntax Help! I don't understand this!

Method: vehicle:getVariant(...)
Counterpart: setVehicleVariant


Required Arguments

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

Returns

Returns 2 int containing the vehicle variants, false otherwise (the specified vehicle doesn't exist).

Example

Click to collapse [-]
Client example

This example tells the player in the vehicle what their vehicle variants are with a command named getvehvar:

function getMyVehicleVariants()
    local myVeh = getPedOccupiedVehicle(localPlayer) -- Get the vehicle that the player is in

    if myVeh then
        local variant1, variant2 = getVehicleVariant (myVeh) -- Get the vehicle variants

        outputChatBox ("This vehicle's variants are: "..tostring (variant1).." "..tostring (variant2)) -- Output the info to chatbox
    end
end

addCommandHandler ("getvehvar", getMyVehicleVariants)

See Also