Removing fuel generator gives back one that doesn't require fuel
When someone removes a Small Fuel Generator, It gives them back a Small Generator that doesnt require fuel. :D

Is there a way to fix that ?

I disabled remove for that generator for the time being.

EDIT: Both of the generators have the same name in the category they are in. Meaning when you remove one, it automatically gives the other first. lol I didn't realize this at first. Now I see why. I dont know how to fix that. FP may have to rename them first. lol

Yes, the one you buy in-game is electric.fuelgenerator.small but when using remove tool on it, it refunds electric.generator.small by mistake.

electric.generator.small (which prior to the September 5th update) was a reskinned mailbox (according to its description) now produces 100 power constantly without needing fuel.

This is a HUGE bug

Players are already exploiting it to get free generators now.  The good kind.
5d6ebc395ad51.png tbird412
This is a HUGE bug

Players are already exploiting it to get free generators now.  The good kind.


In Remover Tool go to "Small Generator" and set it from 1 to 0. Then Reload it!

Then use the Del command with the asset path for the free generator to kill all of them. :D

Yeah just came here to post that solution.  I went digging through the config, figured I'd at least deny them the refund item and POOF it cannot be removed now but can be picked up with a hammer

Works for me
5d6ebc395ad51.png tbird412
Yeah just came here to post that solution.  I went digging through the config, figured I'd at least deny them the refund item and POOF it cannot be removed now but can be picked up with a hammer

Works for me

Thats one thing I didnt do is allow pickup with hammer. How do I do that again ? LOL

You can just copy this code and overwrite the function in the the plugins\RemoverTool.cs (near line ~997)

 void GiveRefund(BasePlayer player, BaseEntity TargetEntity)
        {
            var refund = GetRefund(TargetEntity);
			Puts(TargetEntity.ToString());
			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)); }
            }
        }


It happens because both have the short name "Small Generator".
I just scan for the ID now in this case as workaround.

It will refund correctly the item for both cases

Toliman

You can just copy this code and overwrite the function in the the plugins\RemoverTool.cs (near line ~997)

 void GiveRefund(BasePlayer player, BaseEntity TargetEntity) { var refund = GetRefund(TargetEntity);Puts(TargetEntity.ToString());foreach (KeyValuePair p in refund) {var itemname = p.Key.ToLower(); if (ItemNameToItemID.ContainsKey(itemname)) { var itemid = ItemNameToItemID[itemname];//Start - Fuel Generator Fixif(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)); } } }


It happens because both have the short name "Small Generator".
I just scan for the ID now in this case as workaround.

It will refund correctly the item for both cases

Question, Im no coder, but how long will it take to rewrite the plugin to use Item Id's or Item ShortNames ? Just makes sense to me, Or maybe I dont understand the logic of using the method the dev used. Gotta be a good reason I suppose.

Toliman

You can just copy this code and overwrite the function in the the plugins\RemoverTool.cs (near line ~997)

 void GiveRefund(BasePlayer player, BaseEntity TargetEntity)
        {
            var refund = GetRefund(TargetEntity);
			Puts(TargetEntity.ToString());
			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)); }
            }
        }


It happens because both have the short name "Small Generator".
I just scan for the ID now in this case as workaround.

It will refund correctly the item for both cases

 

(13:06:57) | [Oxide] 13:06 [Error] Error while compiling: RemoverTool.cs(1001,31): error CS0030: Cannot convert type `System.Collections.Generic.KeyValuePair<string,object>' to `System.Collections.Generic.KeyValuePair'
this is what i got when overwriting that function.

Unfortunetly, the latest update adds a "Small Generator" to the game for users, but if you use the remove tool, you get a "admin only" version which is 100 power and no fuel requirement. The issue is Rust named them the exact same, see your Misc tab. 

A work around is to simply disable (1 to 0) the "Small Generator" in the conf file. 

It would be good to have people be able to remove the gen, please see what is available. 

Thanks for the function fix, however I had to add { } around the if statement for the fix like this:

        void GiveRefund(BasePlayer player, BaseEntity TargetEntity)
        {
            var refund = GetRefund(TargetEntity);
			Puts(TargetEntity.ToString());
			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)); }
            }
        }
I  find that it saves me the trouble of having it added to a "no fuel" plugin or tinkering with the .cs file.
void GiveRefund(BasePlayer player, BaseEntity TargetEntity)
        {
            var refund = GetRefund(TargetEntity);
			Puts(TargetEntity.ToString());
			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)); }
            }
        }


It works with this correct I made

Line 998: foreach (KeyValuePair p in refund)


krazy

Question, Im no coder, but how long will it take to rewrite the plugin to use Item Id's or Item ShortNames ? Just makes sense to me, Or maybe I dont understand the logic of using the method the dev used. Gotta be a good reason I suppose.

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.

Toliman


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)); }
            }
        }