Meteor 2 Scripting Functions
Vehicle
bool inVehicle(int objectID)
Get whether an object is in a vehicle.
if (inVehicle(PLAYER_OBJECT))
{
print("Player is in a vehicle");
}
else
{
print("Player is not in a vehicle");
}
int getVehicle(int objectID)
Get the vehicle object ID which an object is in, or the object's ID if not in a vehicle.
print("Object 1's vehicle object is " + getVehicle(1));
print("Player's vehicle object is " + PLAYER_VEHICLE);
bool getInVehicle(int objectID, int vehicleObjectID)
Place an object in a vehicle.
getInVehicle(PLAYER_OBJECT, 1);
Can be called from server or client.
bool getOutOfVehicle(int objectID, bool placeInCentre)
Get an object out of a vehicle.
getOutOfVehicle(PLAYER_OBJECT, false);
getOutOfVehicle(PLAYER_OBJECT, true);
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.
int createVehicleCrew(int objectID)
Create a crew within a vehicle (server only).
createVehicleCrew(10);
Creates and adds a crew member to each empty crew seat. Occupied seats are skipped.
bool changeSeat(int objectID, int seatIndex)
Change an object's seat in a vehicle.
changeSeat(PLAYER_OBJECT, 0);
changeSeat(PLAYER_OBJECT, 1);
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.
int getObjectSeatIndex(int objectID)
Get the seat index in the current vehicle for the specified object.
print(getObjectSeatIndex(PLAYER_OBJECT));
Can be called from server or client.
Returns -1 if not in a vehicle.
array getVehicleOccupants(int objectID, bool includeEmpty=false)
Get a list of all occupants in a vehicle.
array<int> @occupants = getVehicleOccupants(PLAYER_VEHICLE);
for (uint i = 0; i < occupants.length(); i++)
{
print("Seat" + i + ": " + occupants[i]);
}
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.
array getVehicleCrew(int objectID)
Get a list of all crew members in a vehicle.
array<int> @crewObjects = getVehicleCrew(PLAYER_VEHICLE);
for (uint i = 0; i < crewObjects.length(); i++)
{
print("Crew" + i + ": " + crewObjects[i]);
}
Returns an array containing an object ID for each crew member (does not include passengers).
array getVehiclePassengers(int objectID)
Get a list of all passengers in a vehicle.
array<int> @passengers = getVehiclePassengers(PLAYER_VEHICLE);
for (uint i = 0; i < passengers.length(); i++)
{
print("Passenger" + i + ": " + passengers[i]);
}
Returns an array containing an object ID for each passenger (does not include crew).
int getVehicleOccupantsCount(int objectID)
Get the amount of occupants in a vehicle.
print("Player's vehicle has " + getVehicleOccupantsCount(PLAYER_VEHICLE) + " occupants");
array getVehicleSeatsData(int objectID)
Get information about the seats in a vehicle.
array<VehicleSeatData> @seats = getVehicleSeatsData(PLAYER_VEHICLE);
for (uint i = 0; i < seats.length(); i++)
{
print("Seat " + i + " name: " + seats[i].name);
print("Seat " + i + " visible: " + seats[i].visible);
print("Seat " + i + " ownWeapons: " + seats[i].ownWeapons);
for (uint weaponMountIndex = 0; weaponMountIndex < seats[i].weaponMountIndexes.length(); weaponMountIndex++)
{
print("Seat " + i + " weapon mount: " + weaponMountIndex);
}
}
Use getVehicleTypeSeatsData to get the seats data without an object instance.
array getVehicleTypeSeatsData(int objectTypeNumber)
Get information about the seats in a vehicle.
array<VehicleSeatData> @seats = getVehicleTypeSeatsData(getTypeNumber(PLAYER_VEHICLE));
for (uint i = 0; i < seats.length(); i++)
{
print("Seat " + i + " name: " + seats[i].name);
print("Seat " + i + " crew: " + seats[i].crew);
print("Seat " + i + " visible: " + seats[i].visible);
print("Seat " + i + " ownWeapons: " + seats[i].ownWeapons);
for (uint weaponMountIndex = 0; weaponMountIndex < seats[i].weaponMountIndexes.length(); weaponMountIndex++)
{
print("Seat " + i + " weapon mount: " + weaponMountIndex);
}
}
Use getVehicleSeatsData to get the seats data using an object instance.
void hoot(int objectID)
Hoot vehicle horn (server and clients).
hoot(0);
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.
float fuel = getFuel(getLocalPlayerObject());
print("You have " + fuel + " litres of fuel");
Result is in litres.
void setFuel(int objectID, float fuel)
Set the amount of fuel in a vehicle.
setFuel(getLocalPlayerObject(), 20);
Fuel is in litres.
Amount is automatically clamped between 0 and vehicle's fuel capacity.
Can be called from server or client.
void addFuel(int objectID, float fuelToAdd)
Add fuel to a vehicle.
addFuel(getLocalPlayerObject(), 10);
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.
bool isFuelFull(int objectID)
Determine if a vehicle fuel tank is full.
bool full = isFuelFull(getLocalPlayerObject());
print(full);
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).
float getFuelCapacity(int objectID)
Get the fuel capacity of a vehicle in litres.
float capacity = getFuelCapacity(getLocalPlayerObject());
print("Fuel capcity is " + capacity + " litres");
void setFuelCapacity(int objectID, float capacity)
Set the fuel capacity of a vehicle in litres.
setFuelCapacity(getLocalPlayerObject(), 100);
Setting the fuel capacity of a vehicle to 0 makes it not require any fuel.
Can be called from server or client.
float getFuelConsumptionRatio(int objectID)
Get the fuel consumption ratio of a vehicle.
float ratio = getFuelConsumptionRatio(getLocalPlayerObject());
print("Vehicle fuel consumtion ratio is " + ratio);
void setFuelConsumptionRatio(int objectID, float ratio)
Set the fuel consumption ratio of a vehicle.
setFuelConsumptionRatio(getLocalPlayerObject(), 2);
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.
float getPumpFuel(int objectID)
Get the amount of fuel in a fuel pump.
float fuel = getPumpFuel(1);
Result is in litres.
void setPumpFuel(int objectID, float fuel)
Set the amount of fuel in a fuel pump.
setFuel(1, 2000);
Fuel is in litres.
Amount is automatically clamped to above or equal to 0.
Can be called from server or client.
void addPumpFuel(int objectID, float fuelToAdd)
Add fuel to a fuel pump.
addPumpFuel(1, 1000);
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.
float getDefaultFuelPumpCapacity(int objectID)
Get the default fuel pump capacity for a game object.
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");
}
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.
void refuelAtPump(int objectID, int fuelPumpID)
Begin refilling vehicle fuel from a fuel pump.
int vehicleID = 10;
int pumpID = 20;
refuelAtPump(vehicleID, pumpID, -1);
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.
void stopRefueling(int objectID)
Stop an object refueling.
stopRefueling(10);
Can be called from server or client.
int getRefuelingPumpID(int objectID)
Get the pump ID that a vehicle is currently refueling from.
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");
}
Can be called from server or client.
bool getNeedsCarBattery(int objectID)
Determine if a vehicle requires a car battery to function.
bool needsCarBattery = getNeedsCarBattery(getLocalPlayerObject());
print("needsCarBattery = " + needsCarBattery);
bool getHasCarBattery(int objectID)
Determine if a vehicle has a car battery.
bool hasCarBattery = getHasCarBattery(getLocalPlayerObject());
print("hasCarBattery = " + hasCarBattery);
Applicable vehicles with no battery will not start and lights will not work.
void setHasCarBattery(int objectID, bool hasCarBattery)
Install or remove a car battery from a vehicle.
setHasCarBattery(getLocalPlayerObject(), false);
Can be called from server or client.
bool getAutoBrake(int objectID)
Get the automatic brake status of an object.
if (getAutoBrake(0))
{
print("Object will automatically brake");
}
else
{
print("Object will not automatically brake");
}
void setAutoBrake(int objectID, bool autoBrake)
Set the automatic brake status of an object.
bindToWaypoint(0, 1);
setAutoBrake(0, true);
Objects with automatic brake enabled will stop when they are blocked.
Can be called from server or client.
bool getEngineOn(int objectID)
Determine if a vehicle's engine is on.
print(getEngineOn(PLAYER_VEHICLE));
void setEngineOn(int objectID, bool on)
Switch a vehicle's engine on or off.
setEngineOn(PLAYER_VEHICLE, true);
AI vehicles can override this.
Can be called from server or client.
bool getHeadlightsOn(int objectID)
Determine if a vehicle's headlights are on.
print(getHeadlightsOn(PLAYER_VEHICLE));
void setHeadlightsOn(int objectID, bool on)
Switch a vehicle's headlights on or off.
setHeadlightsOn(PLAYER_VEHICLE, true);
Can be called from server or client.
bool getBeaconLightsOn(int objectID)
Determine if a vehicle's beacon lights are on.
print(getBeaconLightsOn(PLAYER_VEHICLE));
void setBeaconLightsOn(int objectID, bool on)
Switch a vehicle's beacon lights on or off.
setBeaconLightsOn(PLAYER_VEHICLE, true);
Can be called from server or client.
bool getNavLightsOn(int objectID)
Determine if a vehicle's navigation lights are on.
print(getNavLightsOn(PLAYER_VEHICLE));
void setNavLightsOn(int objectID, bool on)
Switch a vehicle's navigation lights on or off.
setNavLightsOn(PLAYER_VEHICLE, true);
Can be called from server or client.
Index