MoveObject: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 4: Line 4:


==Syntax==
==Syntax==
bool [[moveObject]] ( [[object]], time, targetx, targety, targetz, targetrx, targetry, targetrz )
<syntaxhighlight lang="lua"> bool moveObject ( object, time, targetx, targety, targetz, targetrx, targetry, targetrz )</syntaxhighlight>


===Required Arguments===
===Required Arguments===
* '''object''': The object that will be moved.
* '''object''': The object that will be moved.
* '''time''': The time in milliseconds the object will arrive at the destination.
* '''time''': The time in milliseconds the object will arrive at the destination.
Line 13: Line 12:
* '''targety''': The Y value of the target position
* '''targety''': The Y value of the target position
* '''targetz''': The Z value of the target position
* '''targetz''': The Z value of the target position
===Optional Arguments===
* '''targetrx''': The X value of the target rotation
* '''targetrx''': The X value of the target rotation
* '''targetry''': The Y value of the target rotation
* '''targetry''': The Y value of the target rotation
* '''targetrz''': The Z value of the target rotation
* '''targetrz''': The Z value of the target rotation
===Returns===
Returns true if the function moved the object succesfully, and returns false otherwise.


==Example==
==Example==
someguy = [[getPlayerFromNick]] ( "someguy" )
<syntaxhighlight lang="lua">someGuy = getPlayerFromNick ( "someGuy" )
  if ( someguy ) then
  if ( someGuy ) then
   x, y, z = [[getPlayerPosition]] ( someguy )
   x, y, z = getPlayerPosition ( someGuy )
   bed = [[createObject]] ( 1700, x + 5, y, z )
   bed = createObject ( 1700, x + 5, y, z )
   [[moveObject]] ( bed, 3000, x, y, z )
   moveObject ( bed, 3000, x, y, z )
   [[serverChat]] ( "Moving a bed towards someguy" )
   outputChatBox ( "Moving a bed towards someguy", player )
  else
  else
   [[serverChat]] ( "Player someguy doesn't exist" )
   outputChatBox ( "Player someguy doesn't exist", player )
  end
  end</syntaxhighlight>

Revision as of 17:05, 18 May 2006

Description

This function will smoothly move an object from its current position/rotation to the given target position/rotation in the given time. If the function fails for some reason, it will return false.

Syntax

 bool moveObject ( object, time, targetx, targety, targetz, targetrx, targetry, targetrz )

Required Arguments

  • object: The object that will be moved.
  • time: The time in milliseconds the object will arrive at the destination.
  • targetx: The X value of the target position
  • targety: The Y value of the target position
  • targetz: The Z value of the target position

Optional Arguments

  • targetrx: The X value of the target rotation
  • targetry: The Y value of the target rotation
  • targetrz: The Z value of the target rotation

Returns

Returns true if the function moved the object succesfully, and returns false otherwise.

Example

someGuy = getPlayerFromNick ( "someGuy" )
 if ( someGuy ) then
   x, y, z = getPlayerPosition ( someGuy )
   bed = createObject ( 1700, x + 5, y, z )
   moveObject ( bed, 3000, x, y, z )
   outputChatBox ( "Moving a bed towards someguy", player )
 else
   outputChatBox ( "Player someguy doesn't exist", player )
 end