Meteor 2 Scripting Functions
Vehicle
void hoot(int objectID)
Hoot vehicle horn (local only).

Example
hoot(0);

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 (server only).

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.

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.

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 (server only).

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.

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 (server only).

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.

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 (server only).

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.

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.

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)
Sto 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 (server only).

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

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 (server only).

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

Comments
Objects with automatic brake enabled will stop when they are blocked.

See also
getAutoBrake

void playerGetInVehicle(int vehicleObjectID)
Place the local player in a vehicle.

Example
playerGetInVehicle(1);

See also
playerGetOutOfVehicle isPlayerInVehicle

void playerGetOutOfVehicle(bool placeInCentre)
Get the local player out of a vehicle.

Example
playerGetOutOfVehicle(false);

See also
playerGetInVehicle isPlayerInVehicle

void isPlayerInVehicle()
Determine if the local player is in a vehicle.

Example
print(isPlayerInVehicle());

See also
playerGetInVehicle playerGetOutOfVehicle

void putOnHorse(int riderObjectID, bool horseObjectID)
Attach an object to ride-on vehicle.

Example
// Attach player to object ID 0
putOnHorse(PLAYER_OBJECT, 0);

See also
kickOffHorse

void kickOffHorse(int riderObjectID)
Detach an object from ride-on vehicle.

Example
// Detach player from ride-on vehicle
kickOffHorse(PLAYER_OBJECT);

See also
putOnHorse

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

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

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_OBJECT, true);

Comments
AI vehicles can override this.

See also
getEngineOn

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

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

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_OBJECT, true);

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_OBJECT));

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_OBJECT, true);

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_OBJECT));

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_OBJECT, true);

See also
getNavLightsOn


Index

Generated on the 23 November 2024 at 08:20:45 (UK Time)