GetObjectScale: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (Fixed example)
No edit summary
 
Line 7: Line 7:
float, float, float getObjectScale ( object theObject )
float, float, float getObjectScale ( object theObject )
</syntaxhighlight>
</syntaxhighlight>
{{OOP||[[object]]:getScale|scale|setObjectScale}}
{{OOP||[[Object]]:getScale|scale|setObjectScale}}
===Required Arguments===
===Required Arguments===
*'''theObject''': the [[object]] you wish to return the scale of.
*'''theObject''': the [[object]] you wish to return the scale of.


===Returns===
===Returns===
* Three [[float]] values indicating the scale of the object on the x, y, and z axis, if successful.
* Three [[float]] values indicating the scale of the object on the x, y, and z axis if successful, ''false'' otherwise.
* ''false'' otherwise.


==Example==
==Example==
<section name="Client" class="client" show="true">
<section name="Client-only Example" class="client" show="true">
This example adds a command ''get_scale'' which create object and prints out a scale of the object.
This example adds a command named ''getscale'' which creates an object and prints out the scale of it.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addCommandHandler( 'get_scale',
addCommandHandler("getscale",
function( )
    function()
local uObject = createObject( 1337, getElementPosition( localPlayer ) )
local theObject = createObject(1337, getElementPosition(localPlayer))
local x, y, z = getObjectScale( uObject )
local x, y, z = getObjectScale(theObject)
outputChatBox( "Object scale on X axis: "..x.." on Y axis: "..y.." on Z axis: "..z )
outputChatBox("Object scale: X: "..x..", Y: "..y.." Z: "..z.."")
end
    end
)
)
</syntaxhighlight>
</syntaxhighlight>

Latest revision as of 14:19, 2 February 2021

This function returns the visible size of an object.

Syntax

float, float, float getObjectScale ( object theObject )

OOP Syntax Help! I don't understand this!

Method: Object:getScale(...)
Variable: .scale
Counterpart: setObjectScale


Required Arguments

  • theObject: the object you wish to return the scale of.

Returns

  • Three float values indicating the scale of the object on the x, y, and z axis if successful, false otherwise.

Example

Click to collapse [-]
Client-only Example

This example adds a command named getscale which creates an object and prints out the scale of it.

addCommandHandler("getscale",
    function()
	local theObject = createObject(1337, getElementPosition(localPlayer))
	local x, y, z = getObjectScale(theObject)
	outputChatBox("Object scale: X: "..x..", Y: "..y.." Z: "..z.."")
    end
)

See Also