예제 #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)
 {
     List<Block> blocks = new List<Block>(new Block[] { Block.BlockList.AIR, Block.BlockList.RED_MUSHROOM, Block.BlockList.BROWN_MUSHROOM, Block.BlockList.RED_FLOWER, Block.BlockList.YELLOW_FLOWER, Block.BlockList.ACTIVE_LAVA, Block.BlockList.ACTIVE_WATER, Block.BlockList.WATER, Block.BlockList.LAVA });
     ushort x = (ushort)(p.Pos.x / 32), z = (ushort)(p.Pos.z / 32), y = (ushort)((p.Pos.y / 32) - 1);
     bool tpd = false;
     while (y > 0) { y--;
         if (p.Level.GetBlock(x, z, y) == Block.BlockList.AIR && p.Level.GetBlock(x, z, (ushort)(y + 1)) == Block.BlockList.AIR && !blocks.Contains(p.Level.GetBlock(x, z, (ushort)(y - 1)))) {
             try { p.SendToPos(new Vector3S((ushort)(p.Pos.x), (ushort)(p.Pos.z), (ushort)((y + 1) * 32))); }
             catch { p.SendMessage("Error while trying to descend!"); return; }
             p.SendMessage("You have descended!"); tpd = true;
             break;
         }
     }
     if (!tpd) { p.SendMessage("No free spaces found below you!"); }
 }
예제 #3
0
 public void Use(Player p, string[] args)
 {
     List<Block> blocks = new List<Block>(new Block[] { Block.BlockList.AIR, Block.BlockList.RED_MUSHROOM, Block.BlockList.BROWN_MUSHROOM, Block.BlockList.RED_FLOWER, Block.BlockList.YELLOW_FLOWER, Block.BlockList.ACTIVE_LAVA, Block.BlockList.ACTIVE_WATER, Block.BlockList.WATER, Block.BlockList.LAVA });
     ushort top = (ushort)(p.Level.Size.y), x = (ushort)(p.Pos.x / 32), y = (ushort)(p.Pos.y / 32), z = (ushort)(p.Pos.z / 32); ;
     bool tpd = false;
     while (y < top) { y++;
         if (p.Level.GetBlock(x, z, y) == Block.BlockList.AIR && p.Level.GetBlock(x, z, (ushort)(y + 1)) == Block.BlockList.AIR && !blocks.Contains(p.Level.GetBlock(x, z, (ushort)(y - 1)))) {
             try { p.SendToPos(new Vector3((ushort)(p.Pos.x), (ushort)(p.Pos.z), (ushort)((y + 1) * 32)), p.Rot); }
             catch { p.SendMessage("An error has occured while trying to ascend!"); return; }
             p.SendMessage("You have ascended!"); tpd = true;
             break;
         }
     }
     if (!tpd) { p.SendMessage("No free spaces found above you!"); }
 }
예제 #4
0
        public void Use(Player p, string[] args)
        {
            PlayerGroup wanted = null;
            if (args.Count() == 1)
            {
                wanted = PlayerGroup.Find(args[0].ToLower()); // will be null if none found.
                if (wanted == null)
                    p.SendMessage("Spcified group doesn't exist.  Using all groups below you...");
            }
            if (wanted != null && wanted.Permission >= p.Group.Permission)
            {
                wanted = null;
                p.SendMessage("Sorry, you can only patrol groups of a lower rank.  Using all groups below you...");
            }
            p.SendMessage("Finding a person " + (wanted == null ? "under you" : "of the specified rank") + " to patrol...");
            ICommand gotoCmd = Command.Find("goto"); //If goto exists, we can use it to go to the new level before teleporting.
            List<Player> allUnder = Server.Players.FindAll(plr => (wanted == null ? true : plr.Group.Permission == wanted.Permission) && plr.Group.Permission < p.Group.Permission && (gotoCmd == null ? p.Level == plr.Level : true));
            if (allUnder.Count == 0)
            {
                p.SendMessage("There are no people " + (wanted == null ? "under your" : "of the specified") + " rank that are " + (gotoCmd == null ? "in your level." : "currently online."));
                return;
            }
            Player found = allUnder[(new Random()).Next(allUnder.Count)];
            p.SendMessage("Player found!  Transporting you to " + found.Color + found.Username + Server.DefaultColor + "!");
            if (p.Level != found.Level)
            {
                //Go to the level first
                gotoCmd.Use(p, new string[] { found.Level.Name });
            }
            if (found.IsLoading)
            {
                p.SendMessage("Waiting for " + found.Color + found.Username + Server.DefaultColor + " to spawn...");

                while (found.IsLoading) { 
                    Thread.Sleep(5);
                } // until event works
            }
            while (p.IsLoading) {
                Thread.Sleep(5);
            } // until event works.
            p.SendToPos(found.Pos, found.Rot);
        }
예제 #5
0
 public void sendToTeamSpawn(Player p)
 {
     if (!GameInProgess()) return;
     ushort x, y, z; int xx, yy, zz;
     x = (ushort)((int)p.Pos.x / 32);
     y = (ushort)((int)p.Pos.z / 32 - 1);
     z = (ushort)((int)p.Pos.y / 32);
     xx = p.Pos.x;
     yy = p.Pos.z;
     zz = p.Pos.y;
     if ((int)p.ExtraData["team"] == 2)
     {
         p.SendToPos(redSpawn);
     }
     else
     {
         p.SendToPos(blueSpawn);
     }
     Thread dropThread = new Thread(new ThreadStart(delegate
     {
         Thread.Sleep(500);
         dropFlag(p, x, y, z, xx, yy, zz);
     }));
     dropThread.Start();
 }
예제 #6
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;
            }
        }
예제 #7
0
        public void OnMove(Player Player, MoveEventArgs args)
        {
            try
            {
                if (Player.Group.Permission < ServerSettings.GetSettingInt("WOMPermission") &&
                    !WomExempt.Contains(Player.Username.ToLower()))
                {
                    if ((bool) (Player.ExtraData.GetIfExist("UsingWoM")) && !Player.IsBeingKicked)
                    {
                        Player.Kick("WoM is not allowed on this server!");
                        args.Cancel();
                    }
                }

            ExtraPlayerData temp = FindPlayer(Player);
            if (temp == null)
                return;
            if (!temp.SentUserType)
            {
                temp.SentUserType = true;
                ZombieHelper.SendUserType(temp);
            }

            #region Anti-Hack
            Vector3S delta = new Vector3S((short)Math.Abs(Player.Pos.x - Player.oldPos.x),
                (short)Math.Abs(Player.Pos.z - Player.oldPos.z),
                (short)Math.Abs(Player.Pos.y - Player.oldPos.y));

            Vector3S delta32 = new Vector3S((short)(Math.Abs(Player.Pos.x - Player.oldPos.x) / 32),
                (short)(Math.Abs(Player.Pos.z - Player.oldPos.z) / 32),
                (short)(Math.Abs(Player.Pos.y - Player.oldPos.y) / 32));

            bool posChanged = ( delta.x != 0 ) || ( delta.y != 0 ) || ( delta.z != 0 );
            bool pos32Changed = (delta.x != 0) || (delta.y != 0) || (delta.z != 0);
            // skip everything if player hasn't moved
            if (!posChanged) return;
            if (!temp.Referee && !temp.Player.IsLoading && !temp.Player.IsBot)
            {
                if (delta.x >= 160) //Allows 5 blocks a second... more than enough with lag
                {
                    if (temp.Spawning == false)
                    {
                        temp.Spawning = true;
                        Player.SendToPos(Player.oldPos);
                        return;
                    }
                }
                else if (delta.z >= 160) //Allows 5 blocks a second... more than enough with lag
                {
                    if (temp.Spawning == false)
                    {
                        temp.Spawning = true;
                        Player.SendToPos(Player.oldPos);
                        return;
                    }
                }
                else if (temp.Spawning == true)
                {
                    temp.Spawning = TriBool.Unknown;
                }
                else if (temp.Spawning == TriBool.Unknown)
                {
                    temp.Spawning = false;
                }

                try
                {
                    if (Player.Pos.y > 64 && !temp.Referee && (Player.Pos.y / 32) < Player.Level.CWMap.Size.y)
                    {
                        if (Block.CanWalkThrough(Player.Level.GetBlock((Player.Pos.x / 32), (Player.Pos.z / 32), (Player.Pos.y / 32) - 2)) &&
                            Block.CanWalkThrough(Player.Level.GetBlock((Player.Pos.x / 32), (Player.Pos.z / 32), (Player.Pos.y / 32) - 3)) &&
                            !Block.CanEscalate(Player.Level.GetBlock((Player.Pos.x / 32), (Player.Pos.z / 32), (Player.Pos.y / 32) - 2)) &&
                            !Block.CanEscalate(Player.Level.GetBlock((Player.Pos.x / 32), (Player.Pos.z / 32), (Player.Pos.y / 32) - 1)) &&
                            !Block.CanEscalate(Player.Level.GetBlock(Player.Pos / 32)))
                        {
                            if ((Player.Pos.y / 32) - (args.FromPosition.y / 32) == 0)
                            {
                                temp.AmountOfTimesInAir++;
                                if (temp.AmountOfTimesInAir == AmountOfChecksInAir)
                                {
                                    temp.Player.Kick("You are not allowed to fly on this server!");
                                    args.Cancel();
                                    return;
                                }
                            }
                            if ((Player.Pos.y / 32) - (args.FromPosition.y / 32) == -1)
                            {
                                temp.AmountOfTimesInAir--;
                            }
                        }
                        else
                        {
                            temp.AmountOfTimesInAir = 0;
                        }
                    }
                    else
                    {
                        temp.AmountOfTimesInAir = 0;
                    }
                }
                catch { }

                try
                {
                    if ((Player.Pos.y / 32) < Player.Level.CWMap.Size.y)
                    {
                        if (!Block.CanWalkThrough(Player.Level.GetBlock((Player.Pos.x / 32), (Player.Pos.z / 32), (Player.Pos.y / 32))) && !temp.Referee && !temp.Player.IsLoggedIn && !temp.Player.IsLoading)
                        {
                            temp.AmountOfNoClips++;
                            if (temp.AmountOfNoClips == AmountOfNoClips)
                            {
                                temp.Player.Kick("You are not allowed to no-clip on this server!");
                                args.Cancel();
                                return;
                            }
                        }
                    }
                }
                catch { }
            }
            #endregion

            #region Tagging Code
            try //Positions error when loading, just incase the error code doesn't fix this already
            {
                if (ZombieRoundEnabled)
                {
                    foreach (ExtraPlayerData Player1 in ExtraPlayerData.ToArray())
                    {
                        Vector3S pos1 = Player1.Player.Pos;
                        foreach (ExtraPlayerData Player2 in ExtraPlayerData.ToArray()) //Double ieterate
                        {
                            Vector3S pos2 = Player2.Player.Pos;

                            if (!Player1.Player.IsLoading && !Player2.Player.IsLoading)
                            {
                                if (Math.Abs(pos1.x - pos2.x) <= 32 && Math.Abs(pos1.y - pos2.y) <= 64 && Math.Abs(pos1.z - pos2.z) <= 32
                                    && Player1 != Player2 && !Player1.Referee && !Player2.Referee && ((Player1.Infected && !Player2.Infected && !CureOn) || (!Player1.Infected && Player2.Infected && CureOn))) //Check if intersecting within a 1 block radii
                                {
                                    ZombieHelper.InfectPlayer(Player1, Player2);
                                    if (StreakPlayer == Player1.Player.Username)
                                    {
                                        StreakAmount++;
                                        if (StreakAmount % 3 == 0)
                                        {
                                            Player.UniversalChat("WHOA! " + Player1.Player.Username + " is on a " + StreakAmount + " streak!");
                                            ZombieHelper.GiveMoney(Player1.Player, ZombieHelper.Random.Next(1, 15));
                                        }
                                    }
                                    else
                                    {
                                        StreakAmount = 0;
                                        StreakPlayer = Player1.Player.Username;
                                    }
                                    EndGame();
                                }
                            }
                        }

                        foreach (Bot Robot in Server.Bots.ToArray()) //Robot Iterate
                        {
                            if (!Player1.Player.IsLoading)
                            {
                                if (Math.Abs(pos1.x - Robot.Player.Pos.x) <= 32 && Math.Abs(pos1.y - Robot.Player.Pos.y) <= 64 && Math.Abs(pos1.z - Robot.Player.Pos.z) <= 32
                                    && !Player1.Referee && !Player1.Infected && Robot.FollowPlayers) //Check if intersecting within a 1 block radii
                                {
                                    ZombieHelper.InfectPlayer(Robot.Player, Player1);
                                    EndGame();
                                }
                            }
                        }
                    }
                }
            }
            catch { }

            try
            {
                if (pos32Changed && ZombieRoundEnabled)
                {
                    temp.AmountMoved++;
                }
            }
            catch{}

            #endregion
            }
            catch { }
        }
예제 #8
0
        public void Use(Player p, string[] args)
        {
            switch (args.Length)
            {
                case 0:
                    Vector3S meep = new Vector3S((short)(p.Level.CWMap.SpawnPos.x * 32 + 16), (short)(p.Level.CWMap.SpawnPos.z * 32 + 16), (short)(p.Level.CWMap.SpawnPos.y * 32));
                    p.SendToPos(meep, new byte[2] { (byte)p.Rot.x, (byte)p.Rot.z });
                    break;
                case 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 " + who.Color + who.Username + Server.DefaultColor + " to spawn...");
                                while (who.IsLoading)
                                    Thread.Sleep(5);

                            }
                        }
                    }
                    p.SendToPos(who.Pos, new byte[2] { (byte)who.Rot.x, (byte)who.Rot.z });
                    break;
                case 2:
                    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 " + two.Color + two.Username + Server.DefaultColor + " to spawn...");
                                while (two.IsLoading)
                                {
                                    Thread.Sleep(5);
                                }
                            }
                        }
                    }
                    one.SendToPos(two.Pos);
                    p.SendMessage(one.Username + " has been succesfully teleported to " + two.Username + "!");
                    break;
                case 3: {
                        short x, z, y;
                        bool[] intParse = { short.TryParse(args[0], out x), short.TryParse(args[1], out z), short.TryParse(args[2], out y) };
                        if (intParse.Contains<bool>(false)) {
                            p.SendMessage("One of your coordinates was har.");
                            return;
                        }
                        else {
                            p.SendToPos(new Vector3S(x, z, y), new byte[2] { (byte)p.Rot.x, (byte)p.Rot.z });
                            p.SendMessage(string.Format("Succesfully teleported to {0}, {1}, {2}!", x, z, y));
                        }
                        break;
                    }
                case 4: {
                        short x, z, y;
                        bool[] intParse = { short.TryParse(args[0], out x), short.TryParse(args[1], out z), short.TryParse(args[2], out y) };
                        if (intParse.Contains<bool>(false)) {
                            p.SendMessage("One of your coordinates was har.");
                            return;
                        }
                        else {
                            ICommand g = Command.Find("goto");
                            if (g == null) { p.SendMessage("You can't teleport to another level"); return; }
                            g.Use(p, new string[] { args[3] });
                            p.SendToPos(new Vector3S(x, z, y), new byte[2] { (byte)p.Rot.x, (byte)p.Rot.z });
                            p.SendMessage(string.Format("Succesfully teleported to {0}, {1}, {2}!", x, z, y));
                        }
                        break;
                    }
                default:
                    p.SendMessage("Invalid arguments!");
                    break;
            }
        }