Scripting/Squirrel/Events/Vehicle/onVehicleMove

From VC-MP Wiki

Jump to: navigation, search

This event is called when a player is driving a vehicle.

Syntax

function onVehicleMove( player, vehicle, oldX, oldY, oldZ, newX, newY, newZ )

Parameters

  • player - The pointer of the driver
  • vehicle - The pointer of the vehicle
  • oldX - Old X coordinate
  • oldY - Old Y coordinate
  • oldZ - Old Z coordinate
  • newX - New X coordinate
  • newY - New Y coordinate
  • newZ - New Z coordinate

Example

This example will move the vehicle back to point (0, 0, 0) if they move too far away from it.

function onVehicleMove( player, vehicle, x1, y1, z1, x2, y2, z2 )
{
     if ( sqrt( x2*x2 + y2*y2 + z2*z2 ) > 50 ) vehicle.Pos = Vector( 0.0, 0.0, 0.0 );
}

Notes

The function vehicle.Pos was used in in this example. More info about it in the corresponding page.

Related Events

Personal tools
squirrel scripting