Meteor 2 Scripting Functions
Vehicle
bool inVehicle(int objectID)
Get whether an object is in a vehicle.

Example
// check if player is in a vehicle
if (inVehicle(PLAYER_OBJECT))
{
    print("Player is in a vehicle");
}
else
{
    print("Player is not in a vehicle");
}

See also
getVehicle getInVehicle getOutOfVehicle

int getVehicle(int objectID)
Get the vehicle object ID which an object is in, or the object's ID if not in a vehicle.

Example 1
// get object ID 1's vehicle object ID
print("Object 1's vehicle object is " + getVehicle(1));

Example 2
// PLAYER_VEHICLE is functionally equivalent to getVehicle(PLAYER_OBJECT)
print("Player's vehicle object is " + PLAYER_VEHICLE);

See also
inVehicle getInVehicle getOutOfVehicle

bool getInVehicle(int objectID, int vehicleObjectID)
Place an object in a vehicle.

Example
// place player in object 1
getInVehicle(PLAYER_OBJECT, 1);

Comments
Can be called from server or client.

See also
getOutOfVehicle inVehicle getVehicle

bool getOutOfVehicle(int objectID, bool placeInCentre)
Get an object out of a vehicle.

Example 1
// get player out of vehicle in a safe position
getOutOfVehicle(PLAYER_OBJECT, false);

Example 2
// get player out of vehicle
getOutOfVehicle(PLAYER_OBJECT, true);

Comments
Setting placeInCentre to false will search for a suitable location for the object to get out, and will fail if a suitable location is not found.
Setting placeInCentre to true will get the object out on top of the vehicle, but is guaranteed to succeed.
Can be called from server or client.

See also
getInVehicle inVehicle getVehicle

int createVehicleCrew(int objectID)
Create a crew within a vehicle (server only).

Example
createVehicleCrew(10);

Comments
Creates and adds a crew member to each empty crew seat. Occupied seats are skipped.

See also
getInVehicle getObjectSeatIndex

bool changeSeat(int objectID, int seatIndex)
Change an object's seat in a vehicle.

Example 1
// move player to driver
changeSeat(PLAYER_OBJECT, 0);

Example 2
// move player to gunner
changeSeat(PLAYER_OBJECT, 1);

Comments
Seat index 0 is the driver seat.
Seat index 1 is the gunner seat.
Seat indexes greater than 1 are passenger seats.
Can be called from server or client.

See also
getInVehicle getObjectSeatIndex

int getObjectSeatIndex(int objectID)
Get the seat index in the current vehicle for the specified object.

Example
// show player seat index in current vehicle
print(getObjectSeatIndex(PLAYER_OBJECT));

Comments
Can be called from server or client.
Returns -1 if not in a vehicle.

See also
changeSeat

array getVehicleOccupants(int objectID, bool includeEmpty=false)
Get a list of all occupants in a vehicle.

Example 1
// list all occupants in player's vehicle
array<int> @occupants = getVehicleOccupants(PLAYER_VEHICLE);
for (uint i = 0; i < occupants.length(); i++)
{
    print("Seat" + i + ": " + occupants[i]);
}

Comments
Returns an array containing an object ID for each seat. If includeEmpty is true and a seat is empty, the object ID will be -1.

See also
getVehicleCrew getVehiclePassengers getVehicleOccupantsCount

array getVehicleCrew(int objectID)
Get a list of all crew members in a vehicle.

Example 1
// list all crew in player's vehicle
array<int> @crewObjects = getVehicleCrew(PLAYER_VEHICLE);
for (uint i = 0; i < crewObjects.length(); i++)
{
    print("Crew" + i + ": " + crewObjects[i]);
}

Comments
Returns an array containing an object ID for each crew member (does not include passengers).

See also
getVehiclePassengers getVehicleOccupants getVehicleOccupantsCount

array getVehiclePassengers(int objectID)
Get a list of all passengers in a vehicle.

Example 1
// list all passengers player's vehicle
array<int> @passengers = getVehiclePassengers(PLAYER_VEHICLE);
for (uint i = 0; i < passengers.length(); i++)
{
    print("Passenger" + i + ": " + passengers[i]);
}

Comments
Returns an array containing an object ID for each passenger (does not include crew).

See also
getVehicleCrew getVehicleOccupants getVehicleOccupantsCount

int getVehicleOccupantsCount(int objectID)
Get the amount of occupants in a vehicle.

Example 1
// list all occupants in player's vehicle
print("Player's vehicle has " + getVehicleOccupantsCount(PLAYER_VEHICLE) + " occupants");

See also
getVehicleOccupants

array getVehicleSeatsData(int objectID)
Get information about the seats in a vehicle.

Example 1
array<VehicleSeatData> @seats = getVehicleSeatsData(PLAYER_VEHICLE);
for (uint i = 0; i < seats.length(); i++)
{
    // Name of seat
    print("Seat " + i + " name: " + seats[i].name);

    // If the object in the seat is visible or hidden
    print("Seat " + i + " visible: " + seats[i].visible);

    // If the object in the seat can fire their own weapons from the seat
    print("Seat " + i + " ownWeapons: " + seats[i].ownWeapons);
    
    // List of weapon mount indexes assigned to this seat
    for (uint weaponMountIndex = 0; weaponMountIndex < seats[i].weaponMountIndexes.length(); weaponMountIndex++)
    {
        print("Seat " + i + " weapon mount: " + weaponMountIndex);
    }
}

Comments
Use getVehicleTypeSeatsData to get the seats data without an object instance.

See also
getVehicleTypeSeatsData

array getVehicleTypeSeatsData(int objectTypeNumber)
Get information about the seats in a vehicle.

Example 1
array<VehicleSeatData> @seats = getVehicleTypeSeatsData(getTypeNumber(PLAYER_VEHICLE));
for (uint i = 0; i < seats.length(); i++)
{
    // Name of seat
    print("Seat " + i + " name: " + seats[i].name);

    // If the object in the seat is a crew member
    print("Seat " + i + " crew: " + seats[i].crew);

    // If the object in the seat is visible or hidden
    print("Seat " + i + " visible: " + seats[i].visible);

    // If the object in the seat can fire their own weapons from the seat
    print("Seat " + i + " ownWeapons: " + seats[i].ownWeapons);

    // List of weapon mount indexes assigned to this seat
    for (uint weaponMountIndex = 0; weaponMountIndex < seats[i].weaponMountIndexes.length(); weaponMountIndex++)
    {
        print("Seat " + i + " weapon mount: " + weaponMountIndex);
    }
}

Comments
Use getVehicleSeatsData to get the seats data using an object instance.

See also
getVehicleSeatsData

void hoot(int objectID)
Hoot vehicle horn (server and clients).

Example
hoot(0);

Comments
Can be called from server or clients and will play on all computers.

float getFuel(int objectID)
Get the amount of fuel in a vehicle.

Example
float fuel = getFuel(getLocalPlayerObject());
print("You have " + fuel + " litres of fuel");

Comments
Result is in litres.

See also
setFuel addFuel isFuelFull

void setFuel(int objectID, float fuel)
Set the amount of fuel in a vehicle.

Example
// put 20 litres of fuel in player vehicle
setFuel(getLocalPlayerObject(), 20);        

Comments
Fuel is in litres.
Amount is automatically clamped between 0 and vehicle's fuel capacity.
Can be called from server or client.

See also
getFuel addFuel

void addFuel(int objectID, float fuelToAdd)
Add fuel to a vehicle.

Example
// add another 10 litres of fuel to player vehicle
addFuel(getLocalPlayerObject(), 10);        

Comments
Fuel is in litres.
Amount to add can be negative.
Final amount is automatically clamped between 0 and vehicle's fuel capacity.
Can be called from server or client.

See also
getFuel addFuel

bool isFuelFull(int objectID)
Determine if a vehicle fuel tank is full.

Example
// is player player vehicle full?
bool full = isFuelFull(getLocalPlayerObject());
print(full);

Comments
It is recommended to use isFuelFull() instead of comparing fuel with capacity directly to avoid float rounding issues (this function compares with an epsilon of 0.1 litres).

See also
getFuel getFuelCapacity

float getFuelCapacity(int objectID)
Get the fuel capacity of a vehicle in litres.

Example
float capacity = getFuelCapacity(getLocalPlayerObject());
print("Fuel capcity is " + capacity + " litres");

See also
setFuelCapacity isFuelFull

void setFuelCapacity(int objectID, float capacity)
Set the fuel capacity of a vehicle in litres.

Example
// allow player vehicle of hold up to 100 litres of fuel
setFuelCapacity(getLocalPlayerObject(), 100);

Comments
Setting the fuel capacity of a vehicle to 0 makes it not require any fuel.
Can be called from server or client.

See also
getFuelCapacity

float getFuelConsumptionRatio(int objectID)
Get the fuel consumption ratio of a vehicle.

Example
float ratio = getFuelConsumptionRatio(getLocalPlayerObject());
print("Vehicle fuel consumtion ratio is " + ratio);

See also
setFuelConsumptionRatio

void setFuelConsumptionRatio(int objectID, float ratio)
Set the fuel consumption ratio of a vehicle.

Example
// double fuel consumption
setFuelConsumptionRatio(getLocalPlayerObject(), 2);

Comments
Change the consumtion ratio to make specified vehicles consume more or less fuel.
The ratio is a simple multiplier.
Can be called from server or client.

See also
getFuelConsumptionRatio

float getPumpFuel(int objectID)
Get the amount of fuel in a fuel pump.

Example
float fuel = getPumpFuel(1);

Comments
Result is in litres.

See also
setPumpFuel addPumpFuel getDefaultFuelPumpCapacity

void setPumpFuel(int objectID, float fuel)
Set the amount of fuel in a fuel pump.

Example
// set fuel pump with object ID 1 to contain 2000 litres of fuel
setFuel(1, 2000);        

Comments
Fuel is in litres.
Amount is automatically clamped to above or equal to 0.
Can be called from server or client.

See also
getPumpFuel addPumpFuel getDefaultFuelPumpCapacity

void addPumpFuel(int objectID, float fuelToAdd)
Add fuel to a fuel pump.

Example
// add another 1000 litres of fuel to pump with object ID of 1.
addPumpFuel(1, 1000);

Comments
Fuel is in litres.
Amount to add can be negative.
Final amount is automatically clamped to be above 0.
Can be called from server or client.

See also
getPumpFuel addPumpFuel getDefaultFuelPumpCapacity

float getDefaultFuelPumpCapacity(int objectID)
Get the default fuel pump capacity for a game object.

Example
// get default fuel pump capacity for object ID 1
int objectID = 1;
float capacity = getDefaultFuelPumpCapacity(objectID);
if(capacity > 0)
{
    print(getDisplayName(objectID) + " is a fuel pump and would normally store up to " + capacity + " litres of fuel");
}
else
{
    print(getDisplayName(objectID) + " is not defined as a fuel pump but can still have pump fuel added using addPumpFuel");
}

Comments
Capacity is taken from object type so cannot be changed in-game. Useful for getting original/max capacity and determining if a pump with no fuel remaining is a fuel pump.

See also
getPumpFuel addPumpFuel

void refuelAtPump(int objectID, int fuelPumpID)
Begin refilling vehicle fuel from a fuel pump.

Example
// refuel vehicle ID 10 from pump ID 20
int vehicleID = 10;
int pumpID = 20;
refuelAtPump(vehicleID, pumpID, -1);

Comments
Refueling will stop when either the vehicle is full, the pump is empty or the vehicle moves further than maxDistance from the pump.
Set maxDistance to -1 to remove the distance limitation.
Can be called from server or client.

See also
getRefuelingPumpID

void stopRefueling(int objectID)
Stop an object refueling.

Example
// stop object ID 10 refueling
stopRefueling(10);

Comments
Can be called from server or client.

See also
stopRefueling

int getRefuelingPumpID(int objectID)
Get the pump ID that a vehicle is currently refueling from.

Example
// determine if vehicle ID 10 is currently refueling
int vehicleID = 10;
int pumpID = getRefuelingPumpID(vehicleID);
if(pumpID != -1)
{
    print("Vehicle is currently being refueled from " + getDisplayName(pumpID));
}
else
{
    print("Vehicle is not currently being refueled");
}

Comments
Can be called from server or client.

See also
getRefuelingPumpID

bool getNeedsCarBattery(int objectID)
Determine if a vehicle requires a car battery to function.

Example
bool needsCarBattery = getNeedsCarBattery(getLocalPlayerObject());
print("needsCarBattery = " + needsCarBattery);

See also
getHasCarBattery setHasCarBattery

bool getHasCarBattery(int objectID)
Determine if a vehicle has a car battery.

Example
bool hasCarBattery = getHasCarBattery(getLocalPlayerObject());
print("hasCarBattery = " + hasCarBattery);

Comments
Applicable vehicles with no battery will not start and lights will not work.

See also
setHasCarBattery getNeedsCarBattery

void setHasCarBattery(int objectID, bool hasCarBattery)
Install or remove a car battery from a vehicle.

Example
// remove car battery from player vehicle
setHasCarBattery(getLocalPlayerObject(), false);

Comments
Can be called from server or client.

See also
getHasCarBattery getNeedsCarBattery

bool getAutoBrake(int objectID)
Get the automatic brake status of an object.

Example
if (getAutoBrake(0))
{
    print("Object will automatically brake");
}
else
{
    print("Object will not automatically brake");
}

See also
setAutoBrake

void setAutoBrake(int objectID, bool autoBrake)
Set the automatic brake status of an object.

Example
bindToWaypoint(0, 1);
setAutoBrake(0, true);

Comments
Objects with automatic brake enabled will stop when they are blocked.
Can be called from server or client.

See also
getAutoBrake

bool getEngineOn(int objectID)
Determine if a vehicle's engine is on.

Example
// show player vehicle engine status
print(getEngineOn(PLAYER_VEHICLE));

See also
setEngineOn

void setEngineOn(int objectID, bool on)
Switch a vehicle's engine on or off.

Example
// switch player vehicle engine on
setEngineOn(PLAYER_VEHICLE, true);

Comments
AI vehicles can override this.
Can be called from server or client.

See also
getEngineOn

bool getHeadlightsOn(int objectID)
Determine if a vehicle's headlights are on.

Example
// show player vehicle headlights status
print(getHeadlightsOn(PLAYER_VEHICLE));

See also
setHeadlightsOn

void setHeadlightsOn(int objectID, bool on)
Switch a vehicle's headlights on or off.

Example
// switch player vehicle headlights on
setHeadlightsOn(PLAYER_VEHICLE, true);

Comments
Can be called from server or client.

See also
getHeadlightsOn

bool getBeaconLightsOn(int objectID)
Determine if a vehicle's beacon lights are on.

Example
// show player vehicle beacon lights status
print(getBeaconLightsOn(PLAYER_VEHICLE));

See also
setBeaconLightsOn

void setBeaconLightsOn(int objectID, bool on)
Switch a vehicle's beacon lights on or off.

Example
// switch player vehicle beacon lights on
setBeaconLightsOn(PLAYER_VEHICLE, true);

Comments
Can be called from server or client.

See also
getBeaconLightsOn

bool getNavLightsOn(int objectID)
Determine if a vehicle's navigation lights are on.

Example
// show player vehicle nav lights status
print(getNavLightsOn(PLAYER_VEHICLE));

See also
setNavLightsOn

void setNavLightsOn(int objectID, bool on)
Switch a vehicle's navigation lights on or off.

Example
// switch player vehicle nav lights on
setNavLightsOn(PLAYER_VEHICLE, true);

Comments
Can be called from server or client.

See also
getNavLightsOn


Index