IsObjectMoving: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(moved IsObjectMoving to IsElementMoving: This "useful" function is not only useful for objects but also for elements like players/vehicles (Also fixed a bug check out talk page))
 
No edit summary
 
(6 intermediate revisions by 5 users not shown)
Line 1: Line 1:
#REDIRECT [[IsElementMoving]]
__NOTOC__
{{Client function}}
{{Added feature/item|1.5.9|1.5.8|20811|This function checks if an [[object]] is moving.}}
 
==Syntax==
<syntaxhighlight lang="lua">bool isObjectMoving ( object theObject )</syntaxhighlight>
{{OOP||[[object]]:isMoving|moving}}
===Required Arguments===
*'''theObject:''' The [[object]] [[element]].
===Returns===
* Returns ''true'' if the [[object]] is moving, ''false'' otherwise.
 
==Example==
This example creates an object when the resource starts and checks if the object is moving:
<syntaxhighlight lang="lua">
addEventHandler ("onClientResourceStart", resourceRoot,
    function ()
        local x, y, z = getElementPosition (localPlayer)
        object = createObject (1239, x, y, z)
 
        moveObject (object, 5000, x, y, z + 5)
    end
)
 
addCommandHandler ("getmoving",
    function (commandName)
        outputChatBox ("Is object "..(isObjectMoving(object) and "moving" or "not moving"))
    end
)
</syntaxhighlight>
 
==Requirements==
{{Requirements|n/a|1.5.8-9.20811|}}
 
==See Also==
{{Client_object_functions}}

Latest revision as of 20:45, 23 September 2021

This function checks if an object is moving.

Syntax

bool isObjectMoving ( object theObject )

OOP Syntax Help! I don't understand this!

Method: object:isMoving(...)
Variable: .moving


Required Arguments

Returns

  • Returns true if the object is moving, false otherwise.

Example

This example creates an object when the resource starts and checks if the object is moving:

addEventHandler ("onClientResourceStart", resourceRoot,
    function ()
        local x, y, z = getElementPosition (localPlayer)
        object = createObject (1239, x, y, z)

        moveObject (object, 5000, x, y, z + 5)
    end
)

addCommandHandler ("getmoving",
    function (commandName)
        outputChatBox ("Is object "..(isObjectMoving(object) and "moving" or "not moving"))
    end
)

Requirements

Minimum server version n/a
Minimum client version 1.5.8-9.20811

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 client="1.5.8-9.20811" />

See Also