コード例 #1
0
 public void Use(Player p, string[] args)
 {
     if (args.Count() != 0)
     {
         Help(p);
         return;
     }
     Vector3 meep = new Vector3((short)(p.Level.SpawnPos.x * 32), (short)(p.Level.SpawnPos.z * 32 + 51), (short)(p.Level.SpawnPos.y * 32));
     p.SendToPos(meep, p.Level.SpawnRot);
 }
コード例 #2
0
 public void Use(Player p, string[] args)
 {
     if (args.Count() != 0)
     {
         Help(p);
         return;
     }
     Vector3 meep = new Vector3((short)(p.Pos.x / 32), (short)(p.Pos.z / 32), (short)(p.Pos.y / 32));
     p.Level.SpawnPos = meep;
     p.Level.SpawnRot = p.Rot;
     p.SendMessage("Spawn location changed.");
 }
コード例 #3
0
        //TODO Make this more customizeable
        public void Use(Player p, string[] args)
        {
            Vector3 size;
            string type = "";
            switch (args.Length) // initialize depending on arguments given
            {
                case 1:
                    size = new Vector3(64, 64, 32);
                    break;
                case 4:
                    size = new Vector3(short.Parse(args[1]), short.Parse(args[2]), short.Parse(args[3]));
                    break;
                case 5:
                    size = new Vector3(short.Parse(args[1]), short.Parse(args[2]), short.Parse(args[3]));
                    type = args[4];
                    break;
                default: Help(p); return;
            }
            if (Level.FindLevel(args[0]) != null)
            {
                p.SendMessage("This level already exists!");
                return;
            }

            Level temp = null;
            switch (type.ToLower()) // experimental type finding
            {
                case "flat":
                    temp = Level.CreateLevel(size, Level.LevelTypes.Flat, args[0]);
                    break;
                default:
                    temp = Level.CreateLevel(size, Level.LevelTypes.Flat, args[0]);
                    break;
            }

            if (temp == null) { p.SendMessage("Level creation failed"); return; } // something is wrong if you get this
            Level.AddLevel(temp);
            Player.UniversalChat("Created level " + args[0] + "!");
        }
コード例 #4
0
        public void Use(Player p, string[] args)
        {
            if (args.Length > 2)
            {
                p.SendMessage("Invalid arguments!");
                return;
            }
            else if (args.Length == 0)
            {
                Vector3 meep = new Vector3((short)(0.5 + p.Level.SpawnPos.x * 32), (short)(0.5 + p.Level.SpawnPos.z * 32), (short)(1 + p.Level.SpawnPos.y * 32));
                p.SendToPos(meep, p.Level.SpawnRot);
            }
            else if (args.Length == 1)
            {
                Player who = Player.Find(args[0]);
                if (who == null || who.IsHidden)
                {
                    p.SendMessage("Player: " + args[0] + " not found!");
                    return;
                }
                else if (who == p)
                {
                    p.SendMessage("Why are you trying to teleport yourself to yourself?");
                    return;
                }
                else if (!ServerSettings.GetSettingBoolean("AllowHigherRankTp") && p.group.permission < who.group.permission)
                {
                    p.SendMessage("You cannot teleport to a player of higher rank!");
                    return;
                }
                else
                {
                    if (p.Level != who.Level)
                    {
                        //Need goto here
                        if (who.IsLoading)
                        {
                            p.SendMessage("Waiting for " + (string)who.ExtraData.GetIfExist("Color") + who.Username + Server.DefaultColor + " to spawn...");
                            while (who.IsLoading)
                                Thread.Sleep(5);

                        }
                    }
                }
                p.SendToPos(who.Pos, who.Rot);
                return;
            }
            else
            {
                Player one = Player.Find(args[0]);
                Player two = Player.Find(args[1]);
                if (one == null || two == null)
                {
                    //Hehe
                    p.SendMessage((one == null && two == null) ? "Players: " + args[0] + " and " + args[1] + " not found!" : "Player: " + ((one == null) ? args[0] : args[1]) + " not found!");
                    return;
                }
                else if (one == p && two == p || one == p)
                {
                    p.SendMessage((two == p) ? "Why are you trying to teleport yourself to yourself?" : "Why not just use /tp " + args[1] + "?");
                    return;
                }
                else if (two == p)
                {
                    p.SendMessage("Why not just use /summon " + args[0] + "?");
                    return;
                }
                else if (p.group.permission < one.group.permission)
                {
                    p.SendMessage("You cannot force a player of higher rank to tp to another player!");
                }
                else
                {
                    if (one.Level != two.Level)
                    {
                        //Need goto here
                        if (two.IsLoading)
                        {
                            p.SendMessage("Waiting for " + (string)two.ExtraData.GetIfExist("Color") + two.Username + Server.DefaultColor + " to spawn...");
                            while (two.IsLoading) {
                                Thread.Sleep(5);
                            }
                        }
                    }
                }
                one.SendToPos(two.Pos, two.Rot);
                p.SendMessage(one.Username + " has been succesfully teleported to " + two.Username + "!");
                return;
            }
        }
コード例 #5
0
        public void Use(Player p, string[] args)
        {
            p.ExtraData.CreateIfNotExist("IsFlying", false);
            p.ExtraData["IsFlying"]  = !(bool)p.ExtraData["IsFlying"];
            if (!(bool)p.ExtraData["IsFlying"])
            {
                return;
            }
            p.SendMessage("You are now flying. &cJump!");

            Thread fly = new Thread(new ThreadStart(delegate
                {
                Vector3 pos;
                Vector3 oldpos = new Vector3();
                List<Vector3> buffer = new List<Vector3>();
                while ((bool)p.ExtraData["IsFlying"])
                {
                    Thread.Sleep(20);
                    if (p.Pos.x == oldpos.x && p.Pos.z == oldpos.z && p.Pos.y == oldpos.y) continue;
                    try
                    {
                        List<Vector3> tempBuffer = new List<Vector3>();
                        List<Vector3> toRemove = new List<Vector3>();
                        ushort x = (ushort)((p.Pos.x) / 32);
                        ushort z = (ushort)((p.Pos.z) / 32);
                        ushort y = (ushort)((p.Pos.y - 60) / 32);
                        try
                        {
                            for (ushort xx = (ushort)(x - 1); xx <= x + 1; xx++)
                            {
                                for (ushort yy = (ushort)(y - 1); yy <= y; yy++)
                                {
                                    for (ushort zz = (ushort)(z - 1); zz <= z + 1; zz++)
                                    {
                                        if (p.Level.GetBlock(xx, zz, yy) == Block.BlockList.AIR)
                                        {
                                            pos.x = (short)xx; pos.y = (short)yy; pos.z = (short)zz;
                                            tempBuffer.Add(pos);
                                        }
                                    }
                                }
                            }
                            foreach (Vector3 cP in tempBuffer)
                            {
                                if (!buffer.Contains(cP))
                                {
                                    buffer.Add(cP);
                                    p.SendBlockChange((ushort)cP.x, (ushort)cP.z, (ushort)cP.y, Block.BlockList.GLASS);
                                }
                            }
                            foreach (Vector3 cP in buffer)
                            {
                                if (!tempBuffer.Contains(cP))
                                {
                                    p.SendBlockChange((ushort)cP.x, (ushort)cP.z, (ushort)cP.y, Block.BlockList.AIR);
                                    toRemove.Add(cP);
                                }
                            }
                            foreach (Vector3 cP in toRemove)
                            {
                                buffer.Remove(cP);
                            }
                            tempBuffer.Clear();
                            toRemove.Clear();
                        }
                        catch { }
                    }
                    catch { }
                    //
                    //p.Pos.CopyTo(oldpos, 0);
                }

                foreach (Vector3 cP in buffer)
                {
                    p.SendBlockChange((ushort)cP.x, (ushort)cP.z, (ushort)cP.y, 0); //Air
                }

                p.SendMessage("Stopped flying");
            }));
            fly.Start();
        }