public override void Execute(PointBlankPlayer executor, string[] args)
        {
            UnturnedPlayer player = (UnturnedPlayer)executor;

            if (args.Length > 1)
            {
                if (!UnturnedPlayer.TryGetPlayer(args[1], out player))
                {
                    UnturnedChat.SendMessage(executor, Translate("PlayerNotFound"), ConsoleColor.Red);
                    return;
                }
            }

            if (UnturnedPlayer.TryGetPlayer(args[0], out UnturnedPlayer pTarget))
            {
                if (player.Metadata.ContainsKey("pPosition"))
                {
                    player.Metadata["pPosition"] = player.Position.Duplicate();
                }
                else
                {
                    player.Metadata.Add("pPosition", player.Position.Duplicate());
                }
                player.Teleport(pTarget.Player.transform.position);
                UnturnedChat.SendMessage(executor, Translate("Teleport_Teleport", player.PlayerName, pTarget.PlayerName), ConsoleColor.Green);
            }
            else
            {
                Node nTarget = LevelNodes.nodes.FirstOrDefault(a => a.type == ENodeType.LOCATION && NameTool.checkNames(args[0], ((LocationNode)a).name));

                if (nTarget == null)
                {
                    UnturnedChat.SendMessage(executor, Translate("Teleport_Invalid"), ConsoleColor.Red);
                    return;
                }

                if (player.Metadata.ContainsKey("pPosition"))
                {
                    player.Metadata["pPosition"] = player.Position.Duplicate();
                }
                else
                {
                    player.Metadata.Add("pPosition", player.Position.Duplicate());
                }
                player.Teleport(nTarget.point);
                UnturnedChat.SendMessage(executor, Translate("Teleport_Teleport", player.PlayerName, ((LocationNode)nTarget).name), ConsoleColor.Green);
            }
        }
        public override void Execute(PointBlankPlayer executor, string[] args)
        {
            if (args.Length > 0)
            {
                if (UnturnedPlayer.TryGetPlayer(args[0], out UnturnedPlayer target))
                {
                    UnturnedServer.Players.ForEach((player) =>
                    {
                        if (player.Metadata.ContainsKey("pPosition"))
                        {
                            player.Metadata["pPosition"] = player.Position.Duplicate();
                        }
                        else
                        {
                            player.Metadata.Add("pPosition", player.Position.Duplicate());
                        }
                        player.Teleport(target.Position);
                    });
                    return;
                }
                Node nTarget = LevelNodes.nodes.FirstOrDefault(a => a.type == ENodeType.LOCATION && NameTool.checkNames(args[0], ((LocationNode)a).name));

                if (nTarget == null)
                {
                    UnturnedChat.SendMessage(executor, Translate("TpAll_Invalid"), ConsoleColor.Red);
                    return;
                }
                UnturnedServer.Players.ForEach((player) =>
                {
                    if (player.Metadata.ContainsKey("pPosition"))
                    {
                        player.Metadata["pPosition"] = player.Position.Duplicate();
                    }
                    else
                    {
                        player.Metadata.Add("pPosition", player.Position.Duplicate());
                    }
                    player.Teleport(nTarget.point);
                });
            }
            else
            {
                if (UnturnedPlayer.IsServer(executor))
                {
                    UnturnedChat.SendMessage(executor, Translate("TargetServer"), ConsoleColor.Red);
                    return;
                }
                UnturnedServer.Players.ForEach((player) =>
                {
                    if (player.Metadata.ContainsKey("pPosition"))
                    {
                        player.Metadata["pPosition"] = player.Position.Duplicate();
                    }
                    else
                    {
                        player.Metadata.Add("pPosition", player.Position.Duplicate());
                    }
                    player.Teleport(((UnturnedPlayer)executor).Position);
                });
            }
        }
Beispiel #3
0
        public override void Execute(PointBlankPlayer executor, string[] args)
        {
            if (args.Length < 2 || !UnturnedPlayer.TryGetPlayer(args[1], out UnturnedPlayer ply))
            {
                if (executor == null)
                {
                    UnturnedChat.SendMessage(executor, Translations["Base_InvalidPlayer"], ConsoleColor.Red);
                    return;
                }

                ply = (UnturnedPlayer)executor;
            }

            if (UnturnedPlayer.TryGetPlayer(args[0], out UnturnedPlayer pTarget))
            {
                ply.Teleport(pTarget.Player.transform.position);
                UnturnedChat.SendMessage(executor, string.Format(Translations["Teleport_Teleport"], ply.PlayerName, pTarget.PlayerName), ConsoleColor.Green);
            }
            else
            {
                Node nTarget = LevelNodes.nodes.FirstOrDefault(a => a.type == ENodeType.LOCATION && NameTool.checkNames(args[0], ((LocationNode)a).name));

                if (nTarget == null)
                {
                    UnturnedChat.SendMessage(executor, Translations["Teleport_Invalid"], ConsoleColor.Red);
                    return;
                }

                ply.Teleport(nTarget.point);
                UnturnedChat.SendMessage(executor, string.Format(Translations["Teleport_Teleport"], ply.PlayerName, ((LocationNode)nTarget).name), ConsoleColor.Green);
            }
        }