Example #1
0
        void HideSleeper(BasePlayer player)
        {
            List <Connection> connections = new List <Connection>();

            foreach (BasePlayer target in BasePlayer.activePlayerList)
            {
                if (player == target || !target.IsConnected)
                {
                    continue;
                }
                connections.Add(target.net.connection);
            }
            HeldEntity heldEntity = player.GetHeldEntity();

            if (heldEntity != null)
            {
                heldEntity.SetHeld(false);
                heldEntity.UpdateVisiblity_Invis();
                heldEntity.SendNetworkUpdate();
            }

            if (Net.sv.write.Start())
            {
                Net.sv.write.PacketID(Message.Type.EntityDestroy);
                Net.sv.write.EntityID(player.net.ID);
                Net.sv.write.UInt8((byte)BaseNetworkable.DestroyMode.None);
                Net.sv.write.Send(new SendInfo(connections));
            }
            player.UpdatePlayerCollider(false);
        }
Example #2
0
        private void Reappear(BasePlayer basePlayer)
        {
            if (onlinePlayers[basePlayer] != null)
            {
                onlinePlayers[basePlayer].IsInvisible = false;
            }
            basePlayer.SendNetworkUpdate();
            basePlayer.limitNetworking = false;

            HeldEntity heldEnity = basePlayer.GetHeldEntity();

            if (heldEnity != null)
            {
                heldEnity.UpdateVisibility_Hand();
                heldEnity.SendNetworkUpdate();
            }

            basePlayer.UpdatePlayerCollider(true);

            string gui;

            if (guiInfo.TryGetValue(basePlayer.userID, out gui))
            {
                CuiHelper.DestroyUi(basePlayer, gui);
            }

            Message(basePlayer.IPlayer, "VanishDisabled");
            if (onlinePlayers.Values.Count(p => p.IsInvisible) <= 0)
            {
                Unsubscribe(nameof(CanNetworkTo));
            }
        }
Example #3
0
        private void Reappear(BasePlayer basePlayer)
        {
            if (onlinePlayers[basePlayer] != null)
            {
                onlinePlayers[basePlayer].IsInvisible = false;
                onlinePlayers[basePlayer].groupSwitchTimer?.Destroy();

                if (basePlayer.GetComponent <WeaponBlock>() != null)
                {
                    GameObject.Destroy(basePlayer.GetComponent <WeaponBlock>());
                }

                if (basePlayer.GetComponent <Runner>() != null)
                {
                    GameObject.Destroy(basePlayer.GetComponent <Runner>());
                }
            }
            basePlayer.syncPosition = true;
            basePlayer.SendNetworkUpdate();
            basePlayer.limitNetworking = false;

            HeldEntity heldEnity = basePlayer.GetHeldEntity();

            if (heldEnity != null)
            {
                heldEnity.UpdateVisibility_Hand();
                heldEnity.SendNetworkUpdate();
            }

            basePlayer.UpdatePlayerCollider(true);

            string gui;

            if (guiInfo.TryGetValue(basePlayer.userID, out gui))
            {
                CuiHelper.DestroyUi(basePlayer, gui);
            }

            Message(basePlayer.IPlayer, "VanishDisabled");

            if (!AnyInvisible)
            {
                Unsubscribe(nameof(CanNetworkTo));
            }

            Interface.CallHook("OnVanishReappear", basePlayer);
            storedData.Invisible.Remove(basePlayer.userID);
        }
Example #4
0
        public static void Reappear(BasePlayer ply)
        {
            if (!ply.IsInvisible)
            {
                return;
            }
            ply.IsInvisible = false;
            ply.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
            HeldEntity heldEntity = ply.GetHeldEntity();

            if (heldEntity != null)
            {
                heldEntity.UpdateVisibility_Hand();
                heldEntity.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
            }
            ply.UpdatePlayerCollider(true);
            CommunityEntity.ServerInstance.ClientRPCEx <string>(new SendInfo
            {
                connection = ply.net.connection
            }, null, "DestroyUI", "InvisibleIndicator");
        }
Example #5
0
        public static void Disappear(BasePlayer ply)
        {
            if (!ply.IsConnected || ply.IsInvisible || ply.HasPlayerFlag(BasePlayer.PlayerFlags.ReceivingSnapshot))
            {
                return;
            }
            List <Connection> list = new List <Connection>();

            foreach (BasePlayer basePlayer in BasePlayer.activePlayerList)
            {
                if (!(ply == basePlayer) && basePlayer.IsConnected && !basePlayer.IsAdmin)
                {
                    list.Add(basePlayer.net.connection);
                }
            }
            HeldEntity heldEntity = ply.GetHeldEntity();

            if (heldEntity != null)
            {
                heldEntity.SetHeld(false);
                heldEntity.UpdateVisiblity_Invis();
                heldEntity.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
            }
            var sv = Network.Net.sv;

            if (sv.write.Start())
            {
                sv.write.PacketID(Message.Type.EntityDestroy);
                sv.write.EntityID(ply.net.ID);
                sv.write.UInt8(0);
                sv.write.Send(new SendInfo(list));
            }
            ply.UpdatePlayerCollider(false);
            CommunityEntity.ServerInstance.ClientRPCEx <string>(new SendInfo
            {
                connection = ply.net.connection
            }, null, "AddUI", "[{\"name\":\"InvisibleIndicator\",\"parent\":\"Hud\",\"components\":[{\"type\":\"UnityEngine.UI.RawImage\",\"url\":\"https://rustasia.com/fa-eye.png\",\"color\":\"1 1 1 0.5\"},{\"type\":\"RectTransform\",\"anchormin\":\"0.175 0.017\",\"anchormax\":\"0.22 0.08\"}]}]");
            ply.IsInvisible = true;
        }
Example #6
0
        private void Disappear(BasePlayer basePlayer, bool showNotification = true)
        {
            if (Interface.CallHook("OnVanishDisappear", basePlayer) != null)
            {
                return;
            }

            OnlinePlayer player;

            if (!onlinePlayers.TryGetValue(basePlayer, out player))
            {
                player = new OnlinePlayer();
                onlinePlayers[basePlayer] = player;
            }

            List <Connection> connections = new List <Connection>();

            foreach (BasePlayer target in BasePlayer.activePlayerList)
            {
                if (basePlayer == target || !target.IsConnected || config.VisibleToAdmin && target.IPlayer.IsAdmin)
                {
                    continue;
                }

                connections.Add(target.net.connection);
            }

            if (config.PerformanceMode)
            {
                basePlayer.limitNetworking = true;
            }

            basePlayer.syncPosition = false;

            HeldEntity heldEntity = basePlayer.GetHeldEntity();

            if (heldEntity != null)
            {
                heldEntity.SetHeld(false);
                heldEntity.UpdateVisiblity_Invis();
                heldEntity.SendNetworkUpdate();
            }

            if (Net.sv.write.Start())
            {
                Net.sv.write.PacketID(Network.Message.Type.EntityDestroy);
                Net.sv.write.EntityID(basePlayer.net.ID);
                Net.sv.write.UInt8((byte)BaseNetworkable.DestroyMode.None);
                Net.sv.write.Send(new SendInfo(connections));
            }

            basePlayer.UpdatePlayerCollider(false);

            player.IsInvisible = true;

            if (player.groupSwitchTimer != null)
            {
                player.groupSwitchTimer.Destroy();
            }

            player.groupSwitchTimer = timer.Every(5f, () =>
            {
                if (basePlayer != null)
                {
                    basePlayer.UpdateNetworkGroup();
                }
            });

            if (basePlayer.GetComponent <WeaponBlock>() == null && basePlayer.IPlayer.HasPermission(permAbilitiesHideWeapons))
            {
                basePlayer.gameObject.AddComponent <WeaponBlock>();
            }

            if (config.AppearWhileRunning && basePlayer.GetComponent <Runner>() == null)
            {
                basePlayer.gameObject.AddComponent <Runner>();
            }

            if (config.VanishTimeout > 0f)
            {
                ulong userId = basePlayer.userID;

                if (timers.ContainsKey(userId))
                {
                    timers[userId].Reset();
                }
                else
                {
                    timers.Add(userId, timer.Once(config.VanishTimeout, () =>
                    {
                        if (basePlayer != null && basePlayer.IsConnected && IsInvisible(basePlayer))
                        {
                            Reappear(basePlayer);
                            Message(basePlayer.IPlayer, "VanishTimedOut");
                        }

                        timers.Remove(userId);
                    }));
                }
            }

            if (!storedData.Invisible.Contains(basePlayer.userID))
            {
                storedData.Invisible.Add(basePlayer.userID);
            }

            Subscribe();

            if (config.ShowGuiIcon)
            {
                VanishGui(basePlayer);
            }

            if (showNotification)
            {
                Message(basePlayer.IPlayer, "VanishEnabled");
            }
        }
Example #7
0
        private void Disappear(BasePlayer basePlayer)
        {
            List <Connection> connections = new List <Connection>();

            foreach (BasePlayer target in BasePlayer.activePlayerList)
            {
                if (basePlayer == target || !target.IsConnected || config.VisibleToAdmin && target.IPlayer.IsAdmin)
                {
                    continue;
                }

                connections.Add(target.net.connection);
            }

            if (config.PerformanceMode)
            {
                basePlayer.limitNetworking = true;
            }

            HeldEntity heldEntity = basePlayer.GetHeldEntity();

            if (heldEntity != null)
            {
                heldEntity.SetHeld(false);
                heldEntity.UpdateVisiblity_Invis();
                heldEntity.SendNetworkUpdate();
            }

            if (Net.sv.write.Start())
            {
                Net.sv.write.PacketID(Network.Message.Type.EntityDestroy);
                Net.sv.write.EntityID(basePlayer.net.ID);
                Net.sv.write.UInt8((byte)BaseNetworkable.DestroyMode.None);
                Net.sv.write.Send(new SendInfo(connections));
            }

            basePlayer.UpdatePlayerCollider(false);

            if (config.ShowGuiIcon)
            {
                VanishGui(basePlayer);
            }

            if (onlinePlayers[basePlayer] != null)
            {
                onlinePlayers[basePlayer].IsInvisible = true;
            }
            Message(basePlayer.IPlayer, "VanishEnabled");

            if (config.VanishTimeout > 0f)
            {
                timer.Once(config.VanishTimeout, () =>
                {
                    if (onlinePlayers[basePlayer] != null && onlinePlayers[basePlayer].IsInvisible)
                    {
                        Reappear(basePlayer);
                        Message(basePlayer.IPlayer, "VanishTimedOut");
                    }
                });
            }

            Subscribe();
        }