Sleeping when appearing?

Hello friends, how can I make sure that the players on my server are always in sleep mode after killing them and every time they appear? On my server, the death screen is skipped after each player spawns and freezes in place, hibernating mode would fix this. I hope you can help, you can test the server yourself. Write iPlayer in the RUST search, he will be the first BOW training

Well, I'm not sure what the answer is.  Nor, do I know what you are trying to accomplish with your Server?  You have a Build Kit, but you cannot craft.  Says you are in Europe, but you're really in Asia (Russia).  I died in the water when I put on my scuba tank and without it I drown.  When I kill my toon (Suicide), each time I am auto spawned in with a full kit of clothing, not frozen.  I got to spar with another player and when he killed me, I respawned just like before.  So, not sure what you're talking about? 

Bottom line, I did not ever freeze ... my ping was 297, highest I ever played ... but I still managed to kill the other player a few times.

Russia is a European effort; comparing it with Asia is stupid. Regarding micro-freezes, I said that every time players appear, there is a slight twitch in place. Perhaps this anti-cheat is blocking permanent rebirth?

Merged post

This happens precisely at the moment of constant rebirth, when you are actively fighting with other players and are often reborn, you start to twitch a little at the moment of appearance

Merged post

I have a plugin that allows you to go to sleep using the /sleep command. I would like to make it so that when a player is killed, he will be in sleep mode after being reborn. Is it possible to do this somehow?

"Russia is a European effort; comparing it with Asia is stupid."

No need to be Rude.  I'm in the Philippines and Russia is north of China, so I see Russia as in Asia.  Even though, it crosses both continents.  There is nothing "Stupid" about this.

As far as you saying "I said that every time players appear, there is a slight twitch in place." No, you never said this.  You may have thought you said this, but you said "freezes in place", and when I was on your server I was barely effected by this slight twitch.  If it happens to all players, then to me, that is fair gameplay.

Did you get this /sleep plugin from UMod?  You should go to the Dev and ask them help.  I'm sure it's possible, but what you are asking should be better directed to the developer of that plugin.

And, please don't be nasty with people on this forum.  We are only trying to help.

 

 

 

During active battles, this twitching can make players angry and nervous. I want to support the comfort of players from different countries. Maybe you know other ways to force a player to go to bed every time they appear and not just at the moment of entering the server, when it tells you that you are sleeping. We need to make it so that after killing a player, he reappears in sleep mode.

Merged post

Thanks for trying to help. I didn't mean to offend you.

Merged post

https://umod.org/plugins/sleep

Merged post

using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using Oxide.Core.Libraries.Covalence;

namespace Oxide.Plugins
{
    [Info("Sleep", "Wulf/lukespragg", "0.2.0", ResourceId = 1156)]
    [Description("Allows players with permission to get a well-rested sleep")]
    public class Sleep : CovalencePlugin
    {
        #region Configuration

        private Configuration config;

        public class Configuration
        {
            [JsonProperty(PropertyName = "Cure while sleeping (true/false)")]
            public bool CureWhileSleeping;

            [JsonProperty(PropertyName = "Heal while sleeping (true/false)")]
            public bool HealWhileSleeping;

            [JsonProperty(PropertyName = "Restore while sleeping (true/false)")]
            public bool RestoreWhileSleeping;

            [JsonProperty(PropertyName = "Curing rate (0 - 100)")]
            public int CuringRate;

            [JsonProperty(PropertyName = "Healing rate (0 - 100)")]
            public int HealingRate;

            [JsonProperty(PropertyName = "Restoration rate (0 - 100)")]
            public int RestorationRate;

            public static Configuration DefaultConfig()
            {
                return new Configuration
                {
                    CureWhileSleeping = false,
                    HealWhileSleeping = true,
                    RestoreWhileSleeping = true,
                    CuringRate = 5,
                    HealingRate = 5,
                    RestorationRate = 5
                };
            }
        }

        protected override void LoadConfig()
        {
            base.LoadConfig();
            try
            {
                config = Config.ReadObject<Configuration>();
                if (config?.HealWhileSleeping == null) SaveConfig();
            }
            catch
            {
                LogWarning($"Could not read oxide/config/{Name}.json, creating new config file");
            }
            LoadDefaultConfig();
        }

        protected override void LoadDefaultConfig() => config = Configuration.DefaultConfig();

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

        #endregion

        #region Localization

        private new void LoadDefaultMessages()
        {
            // English
            lang.RegisterMessages(new Dictionary<string, string>
            {
                ["Command"] = "sleep",
                ["Dirty"] = "You seem to be a bit dirty, go take a dip!",
                ["Hungry"] = "You seem to be a bit hungry, eat something",
                ["NotAllowed"] = "You can't go to sleep right now",
                ["Restored"] = "You have awaken restored and rested!",
                ["Thirsty"] = "You seem to be a bit thirsty, drink something!"
            }, this);
        }

        #endregion

        #region Initialization

        private readonly Dictionary<string, Timer> sleepTimers = new Dictionary<string, Timer>();
        private const string permAllow = "sleep.allow";

        private void Init()
        {
            AddCommandAliases("Command", "SleepCommand");

            permission.RegisterPermission(permAllow, this);
        }

        #endregion

        #region Restoration

        private void Restore(BasePlayer player)
        {
            var bleeding = player.metabolism.bleeding.value;
            var calories = player.metabolism.calories.value;
            var comfort = player.metabolism.comfort.value;
            var heartRate = player.metabolism.heartrate.value;
            var poison = player.metabolism.poison.value;
            var radLevel = player.metabolism.radiation_level.value;
            var radPoison = player.metabolism.radiation_poison.value;
            var temperature = player.metabolism.temperature.value;

            if (config.CureWhileSleeping)
            {
                if (poison > 0) poison = poison - (poison / config.CuringRate);
                if (radLevel > 0) radLevel = radLevel - (radLevel / config.CuringRate);
                if (radPoison > 0) radPoison = radPoison - (radPoison / config.CuringRate);
            }

            if (config.HealWhileSleeping)
            {
                if (bleeding.Equals(1)) bleeding = 0;
                if (player.health < 100) player.health = player.health + (player.health / config.HealingRate);
            }

            if (config.RestoreWhileSleeping)
            {
                if (calories < 1000) calories = calories - (calories / config.RestorationRate);
                if (comfort < 0.5) comfort = comfort + (comfort / config.RestorationRate);
                if (heartRate > 0.5) heartRate = heartRate + (heartRate / config.RestorationRate);
                if (temperature < 20) temperature = temperature + (temperature / config.RestorationRate);
                else temperature = temperature - (temperature / config.RestorationRate);
            }
        }

        private void OnPlayerSleepEnded(BasePlayer basePlayer)
        {
            if (sleepTimers.ContainsKey(basePlayer.UserIDString)) sleepTimers[basePlayer.UserIDString].Destroy();

            var player = players.FindPlayerById(basePlayer.UserIDString);
            if (player == null) return;

            Message(player, "Restored");
            if (basePlayer.metabolism.calories.value < 40) Message(player, "YouAreHungry");
            if (basePlayer.metabolism.dirtyness.value > 0) Message(player, "YouAreDirty");
            if (basePlayer.metabolism.hydration.value < 40) Message(player, "YouAreThirsty");
        }

        #endregion

        #region Command

        private void SleepCommand(IPlayer player, string command, string[] args)
        {
            if (!player.HasPermission(permAllow))
            {
                Message(player, "NotAllowed");
                return;
            }

            var basePlayer = player.Object as BasePlayer;
            basePlayer?.StartSleeping();

            sleepTimers[player.Id] = timer.Every(10f, () =>
            {
                if (!player.IsSleeping)
                {
                    sleepTimers[player.Id].Destroy();
                    return;
                }

                Restore(basePlayer);
            });

            Message(player, "WentToSleep");
        }

        #endregion

        #region Helpers

        private void AddCommandAliases(string key, string command)
        {
            foreach (var language in lang.GetLanguages(this))
            {
                var messages = lang.GetMessages(language, this);
                foreach (var message in messages.Where(m => m.Key.StartsWith(key))) AddCovalenceCommand(message.Value, command);
            }
        }

        private string Lang(string key, string id = null, params object[] args) => string.Format(lang.GetMessage(key, this, id), args);

        private void Message(IPlayer player, string key, params object[] args) => player.Reply(Lang(key, player.Id, args));

        #endregion
    }
}