Actually the code IS using the ID.
1. The function retrieves the item name (electric_fuelgenerator_small)
2. But it looks up its ID via the display Name (Small Generator)
3. Retrieves the wrong ID, since "small generator" is not unique
So maybe the writer could use the short-name (electric.fuelgenerator.small) instead of the display-name (small generator) to retrieve the ID.
Btw, you can remove this line from code:
Puts(TargetEntity.ToString());
It will just spam your Console with the targeted Entity.
I used this line to see the correct short-name but forgot to delete it before posting here. Sorry.
Ok, I did what you said, Its still throwing that error, Ill keep what I changed last night for now because I know that method works for me at least as I tested it on my server. Gave me back a fuel generator every time. :D
(10:25:46) | [Oxide] 10:25 [Error] Error while compiling: RemoverTool.cs(1000,31): error CS0030: Cannot convert type `System.Collections.Generic.KeyValuePair' to `System.Collections.Generic.KeyValuePair'
void GiveRefund(BasePlayer player, BaseEntity TargetEntity)
{
var refund = GetRefund(TargetEntity);
foreach (KeyValuePair p in refund)
{
var itemname = p.Key.ToLower();
if (ItemNameToItemID.ContainsKey(itemname))
{
var itemid = ItemNameToItemID[itemname];
//Start - Fuel Generator Fix
if(TargetEntity.ToString().Contains("small_fuel_generator"))
{
itemid = 1849887541;
}
//End - Fuel Generator Fix
var itemamount = (int)p.Value;
var item = ItemManager.CreateByItemID(itemid, itemamount);
player.GiveItem(item, BaseEntity.GiveItemReason.Generic);
}
else { Interface.Oxide.LogWarning(string.Format("{0} {1} didn't receive refund because {2} doesn't seem to be a valid item name", player.UserIDString, player.displayName, itemname)); }
}
}