Meteor 2 Scripting Functions
Vehicle
void hoot(int objectID)
Hoot vehicle horn (local only).
hoot(0);
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 (server only).
setFuel(getLocalPlayerObject(), 20);
Fuel is in litres.
Amount is automatically clamped between 0 and vehicle's fuel capacity.
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.
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 (server only).
setFuelCapacity(getLocalPlayerObject(), 100);
Setting the fuel capacity of a vehicle to 0 makes it not require any fuel.
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 (server only).
setFuelConsumptionRatio(getLocalPlayerObject(), 2);
Change the consumtion ratio to make specified vehicles consume more or less fuel.
The ratio is a simple multiplier.
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 (server only).
setFuel(1, 2000);
Fuel is in litres.
Amount is automatically clamped to above or equal to 0.
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.
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)
Sto 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 (server only).
setHasCarBattery(getLocalPlayerObject(), false);
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 (server only).
bindToWaypoint(0, 1);
setAutoBrake(0, true);
Objects with automatic brake enabled will stop when they are blocked.
void playerGetInVehicle(int vehicleObjectID)
Place the local player in a vehicle.
playerGetInVehicle(1);
void playerGetOutOfVehicle(bool placeInCentre)
Get the local player out of a vehicle.
playerGetOutOfVehicle(false);
void isPlayerInVehicle()
Determine if the local player is in a vehicle.
print(isPlayerInVehicle());
void putOnHorse(int riderObjectID, bool horseObjectID)
Attach an object to ride-on vehicle.
putOnHorse(PLAYER_OBJECT, 0);
void kickOffHorse(int riderObjectID)
Detach an object from ride-on vehicle.
kickOffHorse(PLAYER_OBJECT);
bool getEngineOn(int objectID)
Determine if a vehicle's engine is on.
print(getEngineOn(PLAYER_OBJECT));
void setEngineOn(int objectID, bool on)
Switch a vehicle's engine on or off.
setEngineOn(PLAYER_OBJECT, true);
AI vehicles can override this.
bool getHeadlightsOn(int objectID)
Determine if a vehicle's headlights are on.
print(getHeadlightsOn(PLAYER_OBJECT));
void setHeadlightsOn(int objectID, bool on)
Switch a vehicle's headlights on or off.
setHeadlightsOn(PLAYER_OBJECT, true);
bool getBeaconLightsOn(int objectID)
Determine if a vehicle's beacon lights are on.
print(getBeaconLightsOn(PLAYER_OBJECT));
void setBeaconLightsOn(int objectID, bool on)
Switch a vehicle's beacon lights on or off.
setBeaconLightsOn(PLAYER_OBJECT, true);
bool getNavLightsOn(int objectID)
Determine if a vehicle's navigation lights are on.
print(getNavLightsOn(PLAYER_OBJECT));
void setNavLightsOn(int objectID, bool on)
Switch a vehicle's navigation lights on or off.
setNavLightsOn(PLAYER_OBJECT, true);
Index