CreateVehicle: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
__NOTOC__
==Description==
==Description==
This function creates a vehicle and returns a handle to the created vehicle. If it fails, it will return false. This can happen if you exceed the upper vehicle limit at 65535 or due to an another unspecified future reason.
This function creates a vehicle and returns a handle to the created vehicle. If it fails, it will return false. This can happen if you exceed the upper vehicle limit at 65535 or due to an another unspecified future reason.


==Syntax==
==Syntax==
  [[vehicle]] createVehicle ( model, x, y, z [, rx, ry, rz ] )
  [[vehicle]] createVehicle ( model, x, y, z, [rx, ry, rz] )
 
===Required Arguments===
* '''model''': The vehicle ID of the vehicle being created.
* '''x''': A floating point number representing the X coordinate on the map.
* '''y''': A floating point number representing the Y coordinate on the map.
* '''z''': A floating point number representing the Z coordinate on the map.
 
===Optional Arguments===
{{OptionalArg}}
* '''rx''': A floating point number representing the rotation about the X axis in Radians.
* '''ry''': A floating point number representing the rotation about the Y axis in Radians.
* '''rz''': A floating point number representing the rotation about the Z axis in Radians.
{{UsingRadians}}


==Example==
==Example==
Line 9: Line 23:
   if ( [[strtok]] ( chat, 1, 32 ) == "!createhydra" ) then
   if ( [[strtok]] ( chat, 1, 32 ) == "!createhydra" ) then
     x, y, z = [[getPlayerPosition]] ( player )
     x, y, z = [[getPlayerPosition]] ( player )
     '''createVehicle''' ( 520, x + 5, y, z )
     [[createVehicle]] ( 520, x + 5, y, z )
     [[playerPM]] ( player, "You got a hydra" )
     [[playerPM]] ( player, "You got a hydra" )
   end
   end
  end
  end

Revision as of 21:27, 24 March 2006

Description

This function creates a vehicle and returns a handle to the created vehicle. If it fails, it will return false. This can happen if you exceed the upper vehicle limit at 65535 or due to an another unspecified future reason.

Syntax

vehicle createVehicle ( model, x, y, z, [rx, ry, rz] )

Required Arguments

  • model: The vehicle ID of the vehicle being created.
  • x: A floating point number representing the X coordinate on the map.
  • y: A floating point number representing the Y coordinate on the map.
  • z: A floating point number representing the Z coordinate on the map.

Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • rx: A floating point number representing the rotation about the X axis in Radians.
  • ry: A floating point number representing the rotation about the Y axis in Radians.
  • rz: A floating point number representing the rotation about the Z axis in Radians.

Template:UsingRadians

Example

function onPlayerChat ( player, chat )
  if ( strtok ( chat, 1, 32 ) == "!createhydra" ) then
    x, y, z = getPlayerPosition ( player )
    createVehicle ( 520, x + 5, y, z )
    playerPM ( player, "You got a hydra" )
  end
end