sarogahtyp 1109 Posted June 15, 2022 I will just continue to post snippets out of my tools class which show how create methods which can be used similar to Arma 3. Here I ll show you SetFuel and later I ll add GetFuel as well. The goal is to have an Arma 3 like fuel setter which uses values between 0 (0%)and 1 (100%) to set the fuel. The challenge is that in AR vehicles can have multiple fuel tanks which are handled by fuelnodes which are "part" of the FuelManagerComponent: Spoiler class SaRo_Tools { // Arma 3 like fuel setter (0.0 ... 0.5 ... 1.0) static void SetFuel ( IEntity vehicle, float fuel ) { //get fuel manager FuelManagerComponent fuelManagerComponent = FuelManagerComponent.Cast (vehicle.FindComponent(FuelManagerComponent)); ref array<BaseFuelNode> a_fuelNodes = {}; fuelManagerComponent.GetFuelNodesList(a_fuelNodes); int fuelNodeCount = a_fuelNodes.Count(); foreach (BaseFuelNode currentFuelNode : a_fuelNodes) { currentFuelNode.SetFuel( fuel * currentFuelNode.GetMaxFuel() ); }; } }; usage example: SaRo_Tools.SetFuel ( pOwnerEntity, 0.0); EDIT: Now we create the fuel getter. But I realized that parts of the fuel setter are needed in the fuel getter as well. Therefore I created an additional method for not doing things twice. Now we have SetFuel, GetFuel and the protected method GetFuelNodes: Spoiler class SaRo_Tools { // ************************* Fuel Tools // Arma 3 like fuel setter (0.0 ... 0.5 ... 1.0) static void SetFuel ( IEntity vehicle, float fuel ) { ref array<BaseFuelNode> a_fuelNodes = GetFuelNodes (vehicle); foreach (BaseFuelNode currentFuelNode : a_fuelNodes) { currentFuelNode.SetFuel( fuel * currentFuelNode.GetMaxFuel() ); }; } // Arma 3 like fuel getter (0.0 ... 0.5 ... 1.0) static float GetFuel ( IEntity vehicle ) { ref array<BaseFuelNode> a_fuelNodes = GetFuelNodes (vehicle); float maxFuel = 0, fuel = 0; foreach (BaseFuelNode currentFuelNode : a_fuelNodes) { maxFuel += currentFuelNode.GetMaxFuel(); fuel += currentFuelNode.GetFuel(); }; //zero divisor failsafe if(maxFuel > 0) return (fuel / maxFuel); return 0.0; } //method for getting all fuel nodes (or fuel tanks) protected static array<BaseFuelNode> GetFuelNodes ( IEntity vehicle ) { //get fuel manager FuelManagerComponent fuelManagerComponent = FuelManagerComponent.Cast (vehicle.FindComponent(FuelManagerComponent)); ref array<BaseFuelNode> a_fuelNodes = {}; fuelManagerComponent.GetFuelNodesList(a_fuelNodes); return a_fuelNodes; } }; usage example: float f_fuelAmount; f_fuelAmount = SaRo_Tools.GetFuel (vehicleEntity); There is one more thing to note about this. If a vehicle has several differently filled tanks and you empty them using the two methods, remember the fuel quantity and then fill them up again, then in the end all the tanks will be the same percentage full, even if they were filled to different percentages beforehand. The overall amount of fuel will be the same as before. This really matters in a very few cases only I think. 2 Share this post Link to post Share on other sites
joemac90 16 Posted June 18, 2022 Thank you, great work just what I was looking for. There is only one problem I have noticed, the UI of the vehicle still shows the fuel in the vehicle, but the vehicle will not start. Share this post Link to post Share on other sites
sarogahtyp 1109 Posted June 18, 2022 Just now, joemac90 said: Thank you, great work just what I was looking for. There is only one problem I have noticed, the UI of the vehicle still shows the fuel in the vehicle, but the vehicle will not start. This is correct. I did notice that as well. the UI fuel gauge does not register the changed fuel amount but idk why and how to fix it currently. Share this post Link to post Share on other sites