using Rust; namespace Oxide.Plugins { [Info("MinigunAutoRepair", "DeutscherRitterPlatz", "1.0.0")] [Description("Automatically repairs Minigun when it reaches 99% damage.")] public class MinigunAutoRepair : RustPlugin { private const string MinigunShortname = "minigun"; private const string PermissionUseMinigun = "minigunautorepair.use"; void Init() { permission.RegisterPermission(PermissionUseMinigun, this); } void OnLoseCondition(Item item, ref float amount) { if (item?.info == null) return; // Check if the item is the Minigun if (item.info.shortname != MinigunShortname) return; // Check if the player has the necessary permission var player = item.GetOwnerPlayer(); if (player == null || !permission.UserHasPermission(player.UserIDString, PermissionUseMinigun)) return; // Check if the condition percentage is 1 or less (99% damage) if ((item.condition / item.maxCondition) <= 0.01f) { // Repair the item item.condition = item.maxCondition; // Notify the player (optional) // PrintToChat(player, "Your Minigun has been automatically repaired!"); } } } }