Meteor 2 Scripting Functions
Vehicle
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