SetVehicleComponentScale: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Initial version)
mNo edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 2: Line 2:
{{Client function}}
{{Client function}}


{{New feature/item|3.0131|1.6.6|14489|
{{New feature/item|4.0140|1.5.6|14489|
This function sets the component scale of a [[vehicle]].
This function sets the component scale of a [[vehicle]].
}}
}}
Line 8: Line 8:
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool setVehicleComponentScale ( vehicle theVehicle, string theComponent, float scaleX, float scaleY, float scaleZ [, string base = "root"] )
bool setVehicleComponentScale ( vehicle theVehicle, string theComponent, float scaleX, float scaleY, float scaleZ [, string base = "parent"] )
</syntaxhighlight>
</syntaxhighlight>
{{OOP||[[vehicle]]:setComponentScale||getVehicleComponentScale}}
{{OOP||[[vehicle]]:setComponentScale||getVehicleComponentScale}}
Line 20: Line 20:


===Optional Arguments===  
===Optional Arguments===  
{{New feature/item|3.0141|1.4.0|7013|
*'''base''': A string representing what the supplied scale (''scaleX'', ''scaleY'', ''scaleZ'') is relative to. It can be one of the following values:
*'''base''': A string representing what the supplied scale (''scaleX'', ''scaleY'', ''scaleZ'') is relative to. It can be one of the following values:
**'''parent''': The scale is relative to the parent component.
**'''parent''': The scale is relative to the parent component.
**'''root''' (default if not specified): The scale is relative to the root component.
**'''root''': The scale is relative to the root component.
**'''world''': The scale is a world scale, relative to the world's center of coordinates.
**'''world''': The scale is a world scale, relative to the world's center of coordinates.
}}


===Returns===  
===Returns===  

Latest revision as of 11:56, 4 September 2024

ADDED/UPDATED IN VERSION 1.5.6 r14489:

This function sets the component scale of a vehicle.

Syntax

bool setVehicleComponentScale ( vehicle theVehicle, string theComponent, float scaleX, float scaleY, float scaleZ [, string base = "parent"] )

OOP Syntax Help! I don't understand this!

Method: vehicle:setComponentScale(...)
Counterpart: getVehicleComponentScale


Required Arguments

  • theVehicle: The vehicle you wish to set component scale.
  • theComponent: A vehicle component (this is the frame name from the model file of the component you wish to modify)
  • scaleX: The new x scale of this component.
  • scaleY: The new y scale of this component.
  • scaleZ: The new z scale of this component.

Optional Arguments

  • base: A string representing what the supplied scale (scaleX, scaleY, scaleZ) is relative to. It can be one of the following values:
    • parent: The scale is relative to the parent component.
    • root: The scale is relative to the root component.
    • world: The scale is a world scale, relative to the world's center of coordinates.

Returns

Returns true if component scale was set successfully, false otherwise.

Example

Example 1: This example would set the scale of the component.

addCommandHandler("scs", -- short for 'set component scale'
    function()
        local theVeh = getPedOccupiedVehicle(localPlayer)
	local getComponent = getVehicleComponents(theVeh) -- returns table with all the components of the vehicle
        if (theVeh) then
            for k in pairs (getComponent) do
		local x, y, z = getVehicleComponentScale(theVeh, k) --get the scale of the component
                setVehicleComponentScale(theVeh, k, x*2, y*2, z*2) -- double the sizes
            end
        end
    end
)

See Also