MoveObject: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 21: Line 21:
  if ( someguy ) then
  if ( someguy ) then
   x, y, z = [[getPlayerPosition]] ( someguy )
   x, y, z = [[getPlayerPosition]] ( someguy )
   someObject = [[createObject]] ( 1700, x + 5, y, z )
   bed = [[createObject]] ( 1700, x + 5, y, z )
   [[moveObject]] ( someObject, 3000, x, y, z )
   [[moveObject]] ( bed, 3000, x, y, z )
   [[serverChat]] ( "Moving a bed towards someguy" )
   [[serverChat]] ( "Moving a bed towards someguy" )
  else
  else
   [[serverChat]] ( "Player someguy doesn't exist" )
   [[serverChat]] ( "Player someguy doesn't exist" )
  end
  end

Revision as of 14:15, 30 March 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
  • targetrx: The X value of the target rotation
  • targetry: The Y value of the target rotation
  • targetrz: The Z value of the target rotation

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 )
  serverChat ( "Moving a bed towards someguy" )
else
  serverChat ( "Player someguy doesn't exist" )
end