CreateVehicle: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 7: Line 7:
==Example==
==Example==
  function onPlayerChat ( player, chat )
  function onPlayerChat ( player, chat )
   if ( strtok ( chat, "!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 )

Revision as of 20:58, 23 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 ] )

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