Voice Prop DLCSolved

Multiple items such as megaphones, portable radio-cassettes, and stationary radio-cassettes reduce the durability value during use. Is there any way to improve it? Like a Tesla coil.

you need a plugin for that

Merged post

using Newtonsoft.Json;
using System.Collections.Generic;

namespace Oxide.Plugins
{
    [Info("DLC", "nivex", "0.1.0")]
    [Description("Prevent condition loss to new DLC items")]
    public class DLC : RustPlugin
    {
        private void OnLoseCondition(Item item, float amount)
        {
            if (!config.Items.TryGetValue(item.info.shortname, out amount))
            {
                return;
            }

            float condition = item.condition;

            NextTick(() =>
            {
                if (!IsValid(item))
                {
                    return;
                }

                item.condition = condition - amount;

                if (item.condition <= 0f)
                {
                    item.OnBroken();
                }
            });
        }
        
        private bool IsValid(Item item)
        {
            if (item == null || !item.IsValid() || item.isBroken)
            {
                return false;
            }

            return true;
        }

        #region Configuration

        private Configuration config;

        private static Dictionary<string, float> DefaultItems
        {
            get
            {
                return new Dictionary<string, float>
                {
                    ["cassette"] = 1f,
                    ["cassette.medium"] = 1f,
                    ["cassette.short"] = 1f,
                    ["megaphone"] = 1f
                };
            }
        }
        
        public class Configuration
        {
            [JsonProperty(PropertyName = "Items")]
            public Dictionary<string, float> Items { get; set; } = DefaultItems;
        }

        protected override void LoadConfig()
        {
            base.LoadConfig();

            try
            {
                config = Config.ReadObject<Configuration>();
            }
            catch
            {

            }

            if (config == null)
            {
                LoadDefaultConfig();
            }

            SaveConfig();
        }

        protected override void SaveConfig() => Config.WriteObject(config);

        protected override void LoadDefaultConfig() => config = new Configuration();

        #endregion
    }
}

this might work. idk, haven't tested it. save as DLC.cs

Oh God! I'll test it Thank you! !!

Merged post

its okay, ty!!

I've tried this but I'm still getting durability loss on megaphone, boombox, etc.

EDIT: OK, never mind I'm a doofus, works great, thank you!

no problem

Only "boombox.deployed" can reduce the durability value, I tried multiple nouns, but it didn't work.

you need to specify the shortname

{
"Items": {
"cassette": 0.0,
"cassette.medium": 0.0,
"cassette.short": 0.0,
"megaphone": 0.0,
"soundlight.deployed": 0.0,
"laserlight.deployed": 0.0,
"boombox": 0.0,
"fun.boomboxportable": 0.0
}
}

its right?The durability of "soundlight" and "laserlight" cannot be reduced by this. Try it on the boombox.

That said, I've tried it many times.



Merged post

After all it did not improve.
Locked automatically