-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathkp_fuel_consumption.sqf
57 lines (47 loc) · 1.82 KB
/
kp_fuel_consumption.sqf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
kp_fuel_consumption.sqf
Author: Wyqer
Website: https://www.killahpotatoes.de
Source & License: https://github.com/Wyqer/A3-Scripts
Date: 2017-02-02
Description:
This script handles the fuel consumption of vehicles, so that refueling will be necessary more often.
Parameters:
_this select 0 - OBJECT - Vehicle
Method:
execVM
Example for initPlayerLocal.sqf:
player addEventHandler ["GetInMan", {[ _this select 2] execVM "scripts\kp_fuel_consumption.sqf";}];
*/
private ["_kp_neutral_consumption","_kp_normal_consumption","_kp_max_consumption"];
// CONFIG START
// Time in Minutes till a full tank depletes when the vehicle is standing with running engine
_kp_neutral_consumption = 180;
// Time in Minutes till a full tank depletes when the vehicle is driving
_kp_normal_consumption = 60;
// Time in Minutes till a full tank depletes when the vehicle is driving at max speed
_kp_max_consumption = 40;
// CONFIG END
// DO NOT EDIT BELOW
if (isDedicated) exitWith {};
if (isNil "kp_fuel_consumption_vehicles") then {
kp_fuel_consumption_vehicles = [];
};
if !((_this select 0) in kp_fuel_consumption_vehicles) then {
kp_fuel_consumption_vehicles pushBack (_this select 0);
while {local (_this select 0)} do {
if (isEngineOn (_this select 0)) then {
if (speed (_this select 0) > 5) then {
if (speed (_this select 0) > (getNumber (configFile >> "CfgVehicles" >> typeOf (_this select 0) >> "maxSpeed") * 0.9)) then {
(_this select 0) setFuel (fuel (_this select 0) - (1 / (_kp_max_consumption * 60)));
} else {
(_this select 0) setFuel (fuel (_this select 0) - (1 / (_kp_normal_consumption * 60)));
};
} else {
(_this select 0) setFuel (fuel (_this select 0) - (1 / (_kp_neutral_consumption * 60)));
};
};
uiSleep 1;
};
kp_fuel_consumption_vehicles deleteAt (kp_fuel_consumption_vehicles find (_this select 0));
};