GetObjectMass: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(OOP)
(→‎Returns: this return -1 if object was never streamed in by client)
 
(One intermediate revision by one other user not shown)
Line 9: Line 9:
float getObjectMass ( object theObject )
float getObjectMass ( object theObject )
</syntaxhighlight>
</syntaxhighlight>
{{OOP||[[object]]:getMass|mass|SetObjectMass}}
{{OOP||[[object]]:getMass|mass|setObjectMass}}
===Required Arguments===
===Required Arguments===
*'''theObject:''' the object whose mass you want to get.
*'''theObject:''' the object whose mass you want to get.
Line 16: Line 16:
* A [[float]] representing the mass of the object.
* A [[float]] representing the mass of the object.
* ''false'' if invalid arguments were passed.
* ''false'' if invalid arguments were passed.
* ''-1'' if object was never streamed in.


==Example==
==Example==

Latest revision as of 16:52, 19 March 2016

This function returns the mass of a specified object.

Syntax

float getObjectMass ( object theObject )

OOP Syntax Help! I don't understand this!

Method: object:getMass(...)
Variable: .mass
Counterpart: setObjectMass


Required Arguments

  • theObject: the object whose mass you want to get.

Returns

  • A float representing the mass of the object.
  • false if invalid arguments were passed.
  • -1 if object was never streamed in.

Example

This script basically creates an object then get's the mass and set's its mass 300 more than it's original mass, then tell the client the old and new mass of the object.

local object = createObject(1337,0,0,3)
local oldMass = getObjectMass(object)
local newMass = oldMass+300.0
setObjectMass(object,newMass)
outputChatBox("Object Old Mass: "..oldMass..", New Mass: "..newMass)

See Also