C#:
using Oxide.Core.Plugins;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Oxide.Core;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("FireTools", "XAVIER", "1.0.1")]
public class FireTools : RustPlugin
{
[PluginReference]
Plugin ImageLibrary;
#region Lang
public static StringBuilder sb = new StringBuilder();
public string GetLang(string LangKey, string userID = null, params object[] args)
{
sb.Clear();
if (args != null)
{
sb.AppendFormat(lang.GetMessage(LangKey, this, userID), args);
return sb.ToString();
}
return lang.GetMessage(LangKey, this, userID);
}
private void LoadMessages()
{
lang.RegisterMessages(new Dictionary<string, string>
{
["NotRepair"] = "Вы не можете починить данный предмет!",
}
, this, "ru");
lang.RegisterMessages(new Dictionary<string, string>
{
["NotRepair"] = "You can not repair this tool!",
}
, this);
}
#endregion
#region Initialized
private Dictionary<ItemDefinition, ItemDefinition> Transmutations;
private readonly List<string> Transmutatable = new List<string>()
{
"chicken.raw",
"humanmeat.raw",
"bearmeat",
"deermeat.raw",
"meat.boar",
"wolfmeat.raw",
"hq.metal.ore",
"metal.ore",
"sulfur.ore",
"horsemeat.raw"
};
void OnServerInitialized()
{
ImageLibrary?.Call("AddImage", "https://gspics.org/images/2025/07/26/Ih2HNm.png", "firetool_jackhammer");
Transmutations = ItemManager.GetItemDefinitions().Where(p => Transmutatable.Contains(p.shortname))
.ToDictionary(p => p, p => p.GetComponent<ItemModCookable>()?.becomeOnCooked);
ItemDefinition wood = ItemManager.FindItemDefinition("wood");
ItemDefinition charcoal = ItemManager.FindItemDefinition("charcoal");
Transmutations.Add(wood, charcoal);
LoadMessages();
}
#endregion
#region Hooks
object OnItemRepair(BasePlayer player, Item item)
{
if (player == null || item == null) return null;
var find = config._listTool.Find(p => p.ShortName == item.info.shortname && p.SkinID == item.skin);
if (find != null)
{
if (!find.isRepair)
{
player.ChatMessage(GetLang("NotRepair", player.UserIDString));
return false;
}
}
return null;
}
void OnDispenserGather(ResourceDispenser dispenser, BaseEntity entity, Item item)
{
if (dispenser == null || entity == null || item == null) return;
BasePlayer player = entity.ToPlayer();
if (player == null) return;
var itemTarget = player.GetActiveItem();
if (itemTarget == null) return;
var find = config._listTool.Find(p => p.ShortName == itemTarget.info.shortname && p.SkinID == itemTarget.skin);
if (find != null)
{
if (find._listitemTools.Contains(item.info.shortname) && Transmutations.ContainsKey(item.info))
item.info = Transmutations[item.info];
}
}
void OnDispenserBonus(ResourceDispenser dispenser, BasePlayer player, Item item)
{
if (dispenser == null || player == null || item == null) return;
var itemTarget = player.GetActiveItem();
if (itemTarget == null) return;
var find = config._listTool.Find(p => p.ShortName == itemTarget.info.shortname && p.SkinID == itemTarget.skin);
if (find != null)
{
if (find._listitemTools.Contains(item.info.shortname) && Transmutations.ContainsKey(item.info))
item.info = Transmutations[item.info];
}
}
#endregion
#region ConsoleCommand
[ConsoleCommand("give.fire")]
void GiveFireTool(ConsoleSystem.Arg args)
{
if (!args.IsAdmin) return;
if (args.Args == null || args.Args.Length < 2)
{
PrintWarning($"Error! Example: give.fire hatchet Sparkless");
return;
}
if (config?. _listTool == null || config._listTool.Count == 0)
{
PrintWarning("Configuration not loaded or empty.");
return;
}
var item = config._listTool.Find(p => p.ShortName == args.Args[0]);
if (item == null)
{
PrintWarning($"Error! Tool '{args.Args[0]}' not found in config.");
return;
}
var target = BasePlayer.Find(args.Args[1]);
if (target == null)
{
PrintWarning($"Error! Player '{args.Args[1]}' not found!");
return;
}
var createItem = ItemManager.CreateByName(item.ShortName, 1, item.SkinID);
if (createItem == null)
{
PrintWarning("Failed to create item!");
return;
}
createItem.SetFlag(global::Item.Flag.OnFire, true);
createItem.name = item.DisplayName;
target.GiveItem(createItem, BaseEntity.GiveItemReason.PickedUp);
}
#endregion
#region Configuration
private PluginConfig config;
protected override void LoadDefaultConfig()
{
config = PluginConfig.DefaultConfig();
}
protected override void LoadConfig()
{
base.LoadConfig();
config = Config.ReadObject<PluginConfig>();
if (config.PluginVersion < Version)
UpdateConfigValues();
Config.WriteObject(config, true);
}
private void UpdateConfigValues()
{
PluginConfig baseConfig = PluginConfig.DefaultConfig();
if (config.PluginVersion < new VersionNumber(0, 0, 1))
{
PrintWarning("Config update detected! Updating config values...");
PrintWarning("Config update completed!");
}
config.PluginVersion = Version;
}
protected override void SaveConfig()
{
Config.WriteObject(config);
}
public class SettingsTools
{
[JsonProperty("ShortName Tool")]
public string ShortName;
[JsonProperty("DisplayName Tool")]
public string DisplayName;
[JsonProperty("SkinID Tool")]
public ulong SkinID;
[JsonProperty("Will it be possible to repair the tool")]
public bool isRepair;
[JsonProperty("List of items that will be recycled by this tool")]
public List<string> _listitemTools = new List<string>();
}
private class PluginConfig
{
[JsonProperty("Tool List")]
public List<SettingsTools> _listTool = new List<SettingsTools>();
[JsonProperty("Verison Configuration")]
public VersionNumber PluginVersion = new VersionNumber();
public static PluginConfig DefaultConfig()
{
return new PluginConfig()
{
_listTool = new List<SettingsTools>()
{
new SettingsTools()
{
ShortName = "hatchet",
DisplayName = "Fire Hatchet",
SkinID = 2570607902,
isRepair = false,
_listitemTools = new List<string>()
{
"chicken.raw",
"humanmeat.raw",
"bearmeat",
"deermeat.raw",
"meat.boar",
"wolfmeat.raw",
"horsemeat.raw",
"wood"
},
},
new SettingsTools()
{
ShortName = "pickaxe",
DisplayName = "Fire Pickaxe",
SkinID = 2570608713,
isRepair = false,
_listitemTools = new List<string>()
{
"chicken.raw",
"humanmeat.raw",
"bearmeat",
"deermeat.raw",
"meat.boar",
"wolfmeat.raw",
"hq.metal.ore",
"metal.ore",
"sulfur.ore",
"horsemeat.raw"
},
},
new SettingsTools()
{
ShortName = "jackhammer",
DisplayName = "Fire Jackhammer",
SkinID = 2570608219,
isRepair = false,
_listitemTools = new List<string>()
{
"chicken.raw",
"humanmeat.raw",
"bearmeat",
"deermeat.raw",
"meat.boar",
"wolfmeat.raw",
"hq.metal.ore",
"metal.ore",
"sulfur.ore",
"horsemeat.raw"
},
},
},
PluginVersion = new VersionNumber(),
};
}
}
#endregion
}
}