getObjectProperty | Multi Theft Auto: Wiki Skip to content

getObjectProperty

Client-side
Server-side
Shared

Pair: setProperty

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


This function gets a property of the specified object.

OOP Syntax Help! I don't understand this!

  • Method:object:getProperty(...)

Syntax

mixed getObjectProperty ( object theObject, string property )
Required Arguments
  • theObject: the object you wish to get a property of.
  • property: the property you want to get the value of:

Returns

  • mixed: value

On success: table for all , 3 floats for center_of_mass or float for other properties

Code Examples

shared
addEventHandler("onClientResourceStart", resourceRoot, function()
local theObject = createObject(980, 0, 0, 0) -- create an object
if theObject then
setObjectProperty(theObject, "center_of_mass", 0, -1, 0) -- set its center of mass
local x, y, z = getObjectProperty(theObject, "center_of_mass") -- get its center of mass
outputChatBox("Object's center of mass: "..tostring(x)..", "..tostring(y)..", "..tostring(z))
end
end)