Error while compiling StackSizeController: 'IFuelSystem' does not contain a definition for 'GetFuelItem' and no accessible extension method 'GetFuelItem' accepting a first argument of type 'IFuelSystem' could be found (are you missing a using directive or an assembly reference?) | Line: 285, Pos: 53
Unable to compile since yesterday's update
Try this.
Replace
private void OnEntitySpawned(Minicopter heli)
{
// Ignore if a known plugin is loaded that adjusts heli fuel.
if (AirFuel != null || GetToDaChoppa != null || VehicleVendorOptions != null)
return;
// Must delay for vendor-spawned helis since the creatorEntity is set after spawn.
NextTick(() =>
{
if (heli == null
// Make sure it's a vendor-spawned heli.
|| !heli.IsSafe()
// Make sure the game hasn't changed unexpectedly.
|| heli.StartingFuelUnits() != -1)
return;
// Try-catch block to handle unexpected errors
try
{
// Get the fuel system and check if it's a StorageContainer
var fuelSystem = heli.GetFuelSystem() as StorageContainer;
if (fuelSystem == null)
return;
// Iterate through the items in the container to find the fuel item
Item fuelItem = null;
foreach (var item in fuelSystem.inventory.itemList)
{
if (item.info.shortname == "lowgradefuel")
{
fuelItem = item;
break;
}
}
if (fuelItem == null
// Ignore other types of fuel since they will have been placed by mods.
|| fuelItem.info.shortname != "lowgradefuel"
// Ignore if the fuel amount is unexpected, since a mod likely adjusted it.
|| fuelItem.amount != fuelItem.info.stackable / 5)
return;
var hookResult = Interface.CallHook("OnVendorHeliFuelAdjust", heli);
if (hookResult is bool && (bool)hookResult == false)
return;
fuelItem.amount = 100;
fuelItem.MarkDirty();
}
catch (Exception ex)
{
// Log the error message
Puts($"Error adjusting fuel for heli: {ex.Message}");
}
});
}
with
private void OnEntitySpawned(Minicopter heli)
{
// Ignore if a known plugin is loaded that adjusts heli fuel.
if (AirFuel != null || GetToDaChoppa != null || VehicleVendorOptions != null)
return;
// Must delay for vendor-spawned helis since the creatorEntity is set after spawn.
NextTick(() =>
{
if (heli == null
// Make sure it's a vendor-spawned heli.
|| !heli.IsSafe()
// Make sure the game hasn't changed unexpectedly.
|| heli.StartingFuelUnits() != -1)
return;
// Try-catch block to handle unexpected errors
try
{
// Get the fuel system and check if it's a StorageContainer
var fuelSystem = heli.GetFuelSystem() as StorageContainer;
if (fuelSystem == null)
return;
// Iterate through the items in the container to find the fuel item
Item fuelItem = null;
foreach (var item in fuelSystem.inventory.itemList)
{
if (item.info.shortname == "lowgradefuel")
{
fuelItem = item;
break;
}
}
if (fuelItem == null
// Ignore other types of fuel since they will have been placed by mods.
|| fuelItem.info.shortname != "lowgradefuel"
// Ignore if the fuel amount is unexpected, since a mod likely adjusted it.
|| fuelItem.amount != fuelItem.info.stackable / 5)
return;
var hookResult = Interface.CallHook("OnVendorHeliFuelAdjust", heli);
if (hookResult is bool && (bool)hookResult == false)
return;
fuelItem.amount = 100;
fuelItem.MarkDirty();
}
catch (Exception ex)
{
// Log the error message
Puts($"Error adjusting fuel for heli: {ex.Message}");
}
});
}
bonjour j ai le meme probleme
Oops, I accidentally posted the same two blocks of code
replace
private void OnEntitySpawned(Minicopter heli)
{
// Ignore if a known plugin is loaded that adjusts heli fuel.
if (AirFuel != null || GetToDaChoppa != null || VehicleVendorOptions != null)
return;
// Must delay for vendor-spawned helis since the creatorEntity is set after spawn.
NextTick(() =>
{
if (heli == null
// Make sure it's a vendor-spawned heli.
|| !heli.IsSafe()
// Make sure the game hasn't changed unexpectedly.
|| heli.StartingFuelUnits() != -1)
return;
var fuelItem = (heli.GetFuelSystem() as EntityFuelSystem)?.GetFuelItem();
if (fuelItem == null
// Ignore other types of fuel since they will have been placed by mods.
|| fuelItem.info.shortname != "lowgradefuel"
// Ignore if the fuel amount is unexpected, since a mod likely adjusted it.
|| fuelItem.amount != fuelItem.info.stackable / 5)
return;
var hookResult = Interface.CallHook("OnVendorHeliFuelAdjust", heli);
if (hookResult is bool && (bool)hookResult == false)
return;
fuelItem.amount = 100;
fuelItem.MarkDirty();
});
}
with
private void OnEntitySpawned(Minicopter heli)
{
// Ignore if a known plugin is loaded that adjusts heli fuel.
if (AirFuel != null || GetToDaChoppa != null || VehicleVendorOptions != null)
return;
// Must delay for vendor-spawned helis since the creatorEntity is set after spawn.
NextTick(() =>
{
if (heli == null
// Make sure it's a vendor-spawned heli.
|| !heli.IsSafe()
// Make sure the game hasn't changed unexpectedly.
|| heli.StartingFuelUnits() != -1)
return;
// Try-catch block to handle unexpected errors
try
{
// Get the fuel system and check if it's a StorageContainer
var fuelSystem = heli.GetFuelSystem() as StorageContainer;
if (fuelSystem == null)
return;
// Iterate through the items in the container to find the fuel item
Item fuelItem = null;
foreach (var item in fuelSystem.inventory.itemList)
{
if (item.info.shortname == "lowgradefuel")
{
fuelItem = item;
break;
}
}
if (fuelItem == null
// Ignore other types of fuel since they will have been placed by mods.
|| fuelItem.info.shortname != "lowgradefuel"
// Ignore if the fuel amount is unexpected, since a mod likely adjusted it.
|| fuelItem.amount != fuelItem.info.stackable / 5)
return;
var hookResult = Interface.CallHook("OnVendorHeliFuelAdjust", heli);
if (hookResult is bool && (bool)hookResult == false)
return;
fuelItem.amount = 100;
fuelItem.MarkDirty();
}
catch (Exception ex)
{
// Log the error message
Puts($"Error adjusting fuel for heli: {ex.Message}");
}
});
}
LordGungaOops, I accidentally posted the same two blocks of code
replaceprivate void OnEntitySpawned(Minicopter heli) { // Ignore if a known plugin is loaded that adjusts heli fuel. if (AirFuel != null || GetToDaChoppa != null || VehicleVendorOptions != null) return; // Must delay for vendor-spawned helis since the creatorEntity is set after spawn. NextTick(() => { if (heli == null // Make sure it's a vendor-spawned heli. || !heli.IsSafe() // Make sure the game hasn't changed unexpectedly. || heli.StartingFuelUnits() != -1) return; var fuelItem = (heli.GetFuelSystem() as EntityFuelSystem)?.GetFuelItem(); if (fuelItem == null // Ignore other types of fuel since they will have been placed by mods. || fuelItem.info.shortname != "lowgradefuel" // Ignore if the fuel amount is unexpected, since a mod likely adjusted it. || fuelItem.amount != fuelItem.info.stackable / 5) return; var hookResult = Interface.CallHook("OnVendorHeliFuelAdjust", heli); if (hookResult is bool && (bool)hookResult == false) return; fuelItem.amount = 100; fuelItem.MarkDirty(); }); }
with
private void OnEntitySpawned(Minicopter heli) { // Ignore if a known plugin is loaded that adjusts heli fuel. if (AirFuel != null || GetToDaChoppa != null || VehicleVendorOptions != null) return; // Must delay for vendor-spawned helis since the creatorEntity is set after spawn. NextTick(() => { if (heli == null // Make sure it's a vendor-spawned heli. || !heli.IsSafe() // Make sure the game hasn't changed unexpectedly. || heli.StartingFuelUnits() != -1) return; // Try-catch block to handle unexpected errors try { // Get the fuel system and check if it's a StorageContainer var fuelSystem = heli.GetFuelSystem() as StorageContainer; if (fuelSystem == null) return; // Iterate through the items in the container to find the fuel item Item fuelItem = null; foreach (var item in fuelSystem.inventory.itemList) { if (item.info.shortname == "lowgradefuel") { fuelItem = item; break; } } if (fuelItem == null // Ignore other types of fuel since they will have been placed by mods. || fuelItem.info.shortname != "lowgradefuel" // Ignore if the fuel amount is unexpected, since a mod likely adjusted it. || fuelItem.amount != fuelItem.info.stackable / 5) return; var hookResult = Interface.CallHook("OnVendorHeliFuelAdjust", heli); if (hookResult is bool && (bool)hookResult == false) return; fuelItem.amount = 100; fuelItem.MarkDirty(); } catch (Exception ex) { // Log the error message Puts($"Error adjusting fuel for heli: {ex.Message}"); } }); }
Didn't work for me.