GetVehicleVariant: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
Line 1: Line 1:
{{Server client function}}
{{Shared function}}
__NOTOC__
__NOTOC__
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]]
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, int getVehicleVariant ( vehicle theVehicle )</syntaxhighlight>
<syntaxhighlight lang="lua">int, int getVehicleVariant ( vehicle theVehicle )</syntaxhighlight>
{{OOP||[[vehicle]]:getVariant||setVehicleVariant}}
{{OOP||[[vehicle]]:getVariant||setVehicleVariant}}
==Required Arguments==
 
*'''theVehicle:''' A handle to the [[vehicle]] that you want to get the variant of.
===Required Arguments===
*'''theVehicle:''' The [[vehicle]] that you want to get the variant of.


==Returns==
==Returns==
On success:
Returns 2 [[int]] containing the vehicle variants, ''false'' otherwise (the specified vehicle doesn't exist).
* '''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==
<section name="Client" class="client" show="true">
<section name="Client example" class="client" show="true">
This example tells the person in the vehicle what their vehicle variants are using: getvehvar
This example tells the [[player]] in the [[vehicle]] what their vehicle variants are with a command named ''getvehvar'':
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function getMyVehiclesVariant()
function getMyVehicleVariants()
     local myVeh = getPedOccupiedVehicle(localPlayer) -- Get the vehicle that they're in
     local myVeh = getPedOccupiedVehicle(localPlayer) -- Get the vehicle that the player is in
     if (myVeh) then
 
         local var1, var2 = getVehicleVariant(myVeh) -- Get the info
     if myVeh then
         outputChatBox("This vehicles variants: "..tostring(var1).." "..tostring(var2)) -- Output the info
         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
end
end
addCommandHandler("getvehvar", getMyVehiclesVariant)
 
addCommandHandler ("getvehvar", getMyVehicleVariants)
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>
==Requirements==
==Requirements==
{{Requirements|1.2|1.2}}
{{Requirements|1.2.0|1.2.0}}
 
==See Also==
==See Also==
{{Vehicle functions}}
{{Vehicle functions}}

Latest revision as of 12:43, 19 September 2021

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)

Requirements

Minimum server version 1.2.0
Minimum client version 1.2.0

Note: Using this feature requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version server="1.2.0" client="1.2.0" />

See Also