Ejemplo n.º 1
0
 public override void Use(Player p, string message)
 {
     if (message != "") { Help(p); return; }
     ushort x = (ushort)((0.5 + p.level.spawnx) * 32);
     ushort y = (ushort)((1 + p.level.spawny) * 32);
     ushort z = (ushort)((0.5 + p.level.spawnz) * 32);
     unchecked
     {
         p.SendPos((byte)-1, x, y, z,
                     p.level.rotx,
                     p.level.roty);
     }
 }
Ejemplo n.º 2
0
        public override void Use(Player p, string message)
        {
            p.onTrain = !p.onTrain;

            if (!p.onTrain) return;

            Thread trainThread = new Thread(new ThreadStart(delegate
            {
                while (p.onTrain)
                {
                    Thread.Sleep(3);

                    ushort x = (ushort)(p.pos[0] / 32);
                    ushort y = (ushort)(p.pos[1] / 32);
                    ushort z = (ushort)(p.pos[2] / 32);

                    for (ushort xx = (ushort)(x - 1); xx <= x + 1; xx++)
                    {
                        for (ushort yy = (ushort)(y - 1); yy <= y + 1; yy++)
                        {
                            for (ushort zz = (ushort)(z - 1); zz <= z + 1; zz++)
                            {
                                if (p.level.GetTile(xx, yy, zz) == Block.train)
                                {
                                    p.invincible = true; p.trainGrab = true;
                                    byte newY = 0;

                                    if (y - yy == -1) newY = 240;
                                    else if (y - yy == 0) newY = 0;
                                    else newY = 8;

                                    unchecked
                                    {
                                        if (x - xx == -1)
                                            if (z - zz == -1) p.SendPos((byte)-1, (ushort)(xx * 32 + 16), (ushort)((yy + 1) * 32 - 2), (ushort)(zz * 32 + 16), (byte)96, newY);
                                            else if (z - zz == 0) p.SendPos((byte)-1, (ushort)(xx * 32 + 16), (ushort)((yy + 1) * 32 - 2), (ushort)(zz * 32 + 16), (byte)64, newY);
                                            else p.SendPos((byte)-1, (ushort)(xx * 32 + 16), (ushort)((yy + 1) * 32 - 2), (ushort)(zz * 32 + 16), (byte)32, newY);
                                        else if (x - xx == 0)
                                            if (z - zz == -1) p.SendPos((byte)-1, (ushort)(xx * 32 + 16), (ushort)((yy + 1) * 32 - 2), (ushort)(zz * 32 + 16), (byte)128, newY);
                                            else if (z - zz == 0) { }
                                            else p.SendPos((byte)-1, (ushort)(xx * 32 + 16), (ushort)((yy + 1) * 32 - 2), (ushort)(zz * 32 + 16), (byte)0, newY);
                                        else
                                            if (z - zz == -1) p.SendPos((byte)-1, (ushort)(xx * 32 + 16), (ushort)((yy + 1) * 32 - 2), (ushort)(zz * 32 + 16), (byte)160, newY);
                                            else if (z - zz == 0) p.SendPos((byte)-1, (ushort)(xx * 32 + 16), (ushort)((yy + 1) * 32 - 2), (ushort)(zz * 32 + 16), (byte)192, newY);
                                            else p.SendPos((byte)-1, (ushort)(xx * 32 + 16), (ushort)((yy + 1) * 32 - 2), (ushort)(zz * 32 + 16), (byte)224, newY);
                                    }
                                    goto skip;
                                }
                            }
                        }
                    }

                    Thread.Sleep(3);
                    p.invincible = false;
                    p.trainGrab = false;
            skip:   ;
                }

                Player.SendMessage(p, "Dismounted");
                Thread.Sleep(1000);
                p.invincible = false;
                p.trainGrab = false;
            }));
            trainThread.Start();
            Player.SendMessage(p, "Stand near a train to mount it");
        }
Ejemplo n.º 3
0
        public override void Use(Player p, string message)
        {
            if (message == "") { Help(p); return; }

            try
            {
                Level foundLevel = Level.Find(message);
                if (foundLevel != null)
                {
                    Level startLevel = p.level;

                    GC.Collect();

                    if (p.level == foundLevel) { Player.SendMessage(p, "You are already in \"" + foundLevel.name + "\"."); return; }
                    if (!p.ignorePermission)
                        if (p.group.Permission < foundLevel.permissionvisit) { Player.SendMessage(p, "You're not allowed to go to " + foundLevel.name + "."); return; }
                    if (foundLevel.locked) { Player.SendMessage(p, "\"" + foundLevel.name + "\" is locked!"); return; }

                    p.Loading = true;
                    foreach (Player pl in Player.players) if (p.level == pl.level && p != pl) p.SendDie(pl.id);
                    foreach (PlayerBot b in PlayerBot.playerbots) if (p.level == b.level) p.SendDie(b.id);

                    Player.GlobalDie(p, true);
                    p.level = foundLevel; p.SendUserMOTD(); p.SendMap();

                    GC.Collect();

                    ushort x = (ushort)((0.5 + foundLevel.spawnx) * 32);
                    ushort y = (ushort)((1 + foundLevel.spawny) * 32);
                    ushort z = (ushort)((0.5 + foundLevel.spawnz) * 32);

                    if (!p.hidden) Player.GlobalSpawn(p, x, y, z, foundLevel.rotx, foundLevel.roty, true);
                    else unchecked { p.SendPos((byte)-1, x, y, z, foundLevel.rotx, foundLevel.roty); }

                    foreach (Player pl in Player.players)
                        if (pl.level == p.level && p != pl && !pl.hidden)
                            p.SendSpawn(pl.id, pl.color + pl.name, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1]);

                    foreach (PlayerBot b in PlayerBot.playerbots)
                        if (b.level == p.level)
                            p.SendSpawn(b.id, b.color + b.name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]);

                    if (!p.hidden) Player.GlobalChat(p, p.color + "*" + p.name + Server.DefaultColor + " went to &b" + foundLevel.name, false);

                    p.Loading = false;

                    bool skipUnload = false;
                    if (startLevel.unload && !startLevel.name.Contains("&cMuseum "))
                    {
                        foreach (Player pl in Player.players) if (pl.level == startLevel) skipUnload = true;
                        if (!skipUnload && Server.AutoLoad) startLevel.Unload();
                    }
                }
                else if (Server.AutoLoad)
                {
                    Command.all.Find("load").Use(p, message);
                    foundLevel = Level.Find(message);
                    if (foundLevel != null) Use(p, message);
                }
                else Player.SendMessage(p, "There is no level \"" + message + "\" loaded.");

                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
            catch (Exception e) { Server.ErrorLog(e); }
        }
Ejemplo n.º 4
0
        public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
        {
            byte by = p.level.GetTile(x, y, z);

            p.SendBlockchange(x, y, z, by);
            Pos bp = (Pos)p.blockchangeObject;

            double a = Math.Sin(((double)(128 - p.rot[0]) / 256) * 2 * Math.PI);
            double b = Math.Cos(((double)(128 - p.rot[0]) / 256) * 2 * Math.PI);
            double c = Math.Cos(((double)(p.rot[1] + 64) / 256) * 2 * Math.PI);

            double bigDiag = Math.Sqrt(Math.Sqrt(p.level.width * p.level.width + p.level.height * p.level.height) + p.level.depth * p.level.depth + p.level.width * p.level.width);

            List <CatchPos> previous  = new List <CatchPos>();
            List <CatchPos> allBlocks = new List <CatchPos>();
            CatchPos        pos;

            if (p.modeType != Block.air)
            {
                type = p.modeType;
            }

            Thread gunThread = new Thread(new ThreadStart(delegate
            {
                ushort startX = (ushort)(p.pos[0] / 32);
                ushort startY = (ushort)(p.pos[1] / 32);
                ushort startZ = (ushort)(p.pos[2] / 32);

                pos.x = (ushort)Math.Round(startX + (double)(a * 3));
                pos.y = (ushort)Math.Round(startY + (double)(c * 3));
                pos.z = (ushort)Math.Round(startZ + (double)(b * 3));

                for (double t = 4; bigDiag > t; t++)
                {
                    pos.x = (ushort)Math.Round(startX + (double)(a * t));
                    pos.y = (ushort)Math.Round(startY + (double)(c * t));
                    pos.z = (ushort)Math.Round(startZ + (double)(b * t));

                    by = p.level.GetTile(pos.x, pos.y, pos.z);

                    if (by != Block.air && !allBlocks.Contains(pos))
                    {
                        if (p.level.physics < 2 || bp.ending <= 0)
                        {
                            break;
                        }
                        else
                        {
                            if (bp.ending == 1)
                            {
                                if ((!Block.LavaKill(by) && !Block.NeedRestart(by)) && by != Block.glass)
                                {
                                    break;
                                }
                            }
                            else if (p.level.physics >= 3)
                            {
                                if (by != Block.glass)
                                {
                                    p.level.MakeExplosion(pos.x, pos.y, pos.z, 1);
                                    break;
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                    }

                    p.level.Blockchange(pos.x, pos.y, pos.z, type);
                    previous.Add(pos);
                    allBlocks.Add(pos);

                    bool comeOut = false;
                    foreach (Player pl in Player.players)
                    {
                        if (pl.level == p.level)
                        {
                            if ((ushort)(pl.pos[0] / 32) == pos.x || (ushort)(pl.pos[0] / 32 + 1) == pos.x || (ushort)(pl.pos[0] / 32 - 1) == pos.x)
                            {
                                if ((ushort)(pl.pos[1] / 32) == pos.y || (ushort)(pl.pos[1] / 32 + 1) == pos.y || (ushort)(pl.pos[1] / 32 - 1) == pos.y)
                                {
                                    if ((ushort)(pl.pos[2] / 32) == pos.z || (ushort)(pl.pos[2] / 32 + 1) == pos.z || (ushort)(pl.pos[2] / 32 - 1) == pos.z)
                                    {
                                        if (p.level.ctfmode && !p.level.ctfgame.friendlyfire && p.team == pl.team)
                                        {
                                            comeOut = true;
                                            break;
                                        }
                                        if (p.level.ctfmode)
                                        {
                                            pl.health = pl.health - 25;
                                            if (pl.health > 0)
                                            {
                                                pl.SendMessage("You have been shot!  You have &c" + pl.health + Server.DefaultColor + " health remaining.");
                                                comeOut = true;
                                                break;
                                            }
                                        }


                                        if (p.level.physics >= 3 && bp.ending >= 2)
                                        {
                                            pl.HandleDeath(Block.stone, " was blown up by " + p.color + p.name, true);
                                        }
                                        else
                                        {
                                            pl.HandleDeath(Block.stone, " was shot by " + p.color + p.name);
                                        }
                                        comeOut = true;
                                    }
                                }
                            }
                        }
                    }
                    if (comeOut)
                    {
                        break;
                    }

                    if (t > 12 && bp.ending != 3)
                    {
                        pos = previous[0];
                        p.level.Blockchange(pos.x, pos.y, pos.z, Block.air);
                        previous.Remove(pos);
                    }

                    if (bp.ending != 3)
                    {
                        Thread.Sleep(20);
                    }
                }

                if (bp.ending == -1)
                {
                    try
                    {
                        unchecked { p.SendPos((byte)-1, (ushort)(previous[previous.Count - 3].x * 32), (ushort)(previous[previous.Count - 3].y * 32 + 32), (ushort)(previous[previous.Count - 3].z * 32), p.rot[0], p.rot[1]); }
                    } catch { }
                }
                if (bp.ending == 3)
                {
                    Thread.Sleep(400);
                }

                foreach (CatchPos pos1 in previous)
                {
                    p.level.Blockchange(pos1.x, pos1.y, pos1.z, Block.air);
                    if (bp.ending != 3)
                    {
                        Thread.Sleep(20);
                    }
                }
            }));

            gunThread.Start();
        }
Ejemplo n.º 5
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                message = "list";
            }

            string[] parameters = message.Split(' ');

            if (parameters[0].ToLower() == "list")
            {
                if (parameters.Length > 1)
                {
                    int pageNum, currentNum;
                    try
                    {
                        pageNum = int.Parse(parameters[1]) * 10; currentNum = pageNum - 10;
                    }
                    catch { Help(p); return; }

                    if (currentNum < 0)
                    {
                        Player.SendMessage(p, "Must be greater than 0"); return;
                    }
                    if (pageNum > p.level.ZoneList.Count)
                    {
                        pageNum = p.level.ZoneList.Count;
                    }
                    if (currentNum > p.level.ZoneList.Count)
                    {
                        Player.SendMessage(p, "No Zones beyond number " + (p.level.ZoneList.Count - 1)); return;
                    }

                    Player.SendMessage(p, "Zones (" + currentNum + " to " + (pageNum - 1) + "):");
                    for (int i = currentNum; i < pageNum; i++)
                    {
                        Level.Zone zone = p.level.ZoneList[i];
                        Player.SendMessage(p, "&c" + i + " &b(" +
                                           zone.smallX + "-" + zone.bigX + ", " +
                                           zone.smallY + "-" + zone.bigY + ", " +
                                           zone.smallZ + "-" + zone.bigZ + ") &f" +
                                           zone.Owner);
                    }
                }
                else
                {
                    for (int i = 0; i < p.level.ZoneList.Count; i++)
                    {
                        Level.Zone zone = p.level.ZoneList[i];
                        Player.SendMessage(p, "&c" + i + " &b(" +
                                           zone.smallX + "-" + zone.bigX + ", " +
                                           zone.smallY + "-" + zone.bigY + ", " +
                                           zone.smallZ + "-" + zone.bigZ + ") &f" +
                                           zone.Owner);
                    }
                    Player.SendMessage(p, "For a more structured list, use /tpzone list <1/2/3/..>");
                }
            }
            else
            {
                int zoneID;
                try
                {
                    zoneID = int.Parse(message);
                }
                catch { Help(p); return; }

                if (zoneID < 0 || zoneID > p.level.ZoneList.Count)
                {
                    Player.SendMessage(p, "This zone doesn't exist");
                    return;
                }

                Level.Zone zone = p.level.ZoneList[zoneID];
                unchecked { p.SendPos((byte)-1, (ushort)(zone.bigX * 32 + 16), (ushort)(zone.bigY * 32 + 32), (ushort)(zone.bigZ * 32 + 16), p.rot[0], p.rot[1]); }

                Player.SendMessage(p, "Teleported to zone &c" + zoneID + " &b(" +
                                   zone.bigX + ", " + zone.bigY + ", " + zone.bigZ + ") &f" +
                                   zone.Owner);
            }
        }
Ejemplo n.º 6
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                Help(p); return;
            }

            try
            {
                Level foundLevel = Level.Find(message);
                if (foundLevel != null)
                {
                    Level startLevel = p.level;

                    GC.Collect();

                    if (p.level == foundLevel)
                    {
                        Player.SendMessage(p, "You are already in \"" + foundLevel.name + "\"."); return;
                    }
                    if (!p.ignorePermission)
                    {
                        if (p.group.Permission < foundLevel.permissionvisit)
                        {
                            Player.SendMessage(p, "You're not allowed to go to " + foundLevel.name + "."); return;
                        }
                    }

                    p.Loading = true;
                    foreach (Player pl in Player.players)
                    {
                        if (p.level == pl.level && p != pl)
                        {
                            p.SendDie(pl.id);
                        }
                    }
                    foreach (PlayerBot b in PlayerBot.playerbots)
                    {
                        if (p.level == b.level)
                        {
                            p.SendDie(b.id);
                        }
                    }

                    Player.GlobalDie(p, true);
                    p.level = foundLevel; p.SendUserMOTD(); p.SendMap();

                    GC.Collect();

                    ushort x = (ushort)((0.5 + foundLevel.spawnx) * 32);
                    ushort y = (ushort)((1 + foundLevel.spawny) * 32);
                    ushort z = (ushort)((0.5 + foundLevel.spawnz) * 32);

                    if (!p.hidden)
                    {
                        Player.GlobalSpawn(p, x, y, z, foundLevel.rotx, foundLevel.roty, true);
                    }
                    else
                    {
                        unchecked { p.SendPos((byte)-1, x, y, z, foundLevel.rotx, foundLevel.roty); }
                    }

                    foreach (Player pl in Player.players)
                    {
                        if (pl.level == p.level && p != pl && !pl.hidden)
                        {
                            p.SendSpawn(pl.id, pl.color + pl.name, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1]);
                        }
                    }

                    foreach (PlayerBot b in PlayerBot.playerbots)
                    {
                        if (b.level == p.level)
                        {
                            p.SendSpawn(b.id, b.color + b.name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]);
                        }
                    }

                    if (!p.hidden)
                    {
                        Player.GlobalChat(p, p.color + "*" + p.name + Server.DefaultColor + " went to &b" + foundLevel.name, false);
                    }

                    p.Loading = false;

                    bool skipUnload = false;
                    if (startLevel.unload && !startLevel.name.Contains("&cMuseum "))
                    {
                        foreach (Player pl in Player.players)
                        {
                            if (pl.level == startLevel)
                            {
                                skipUnload = true;
                            }
                        }
                        if (!skipUnload && Server.AutoLoad)
                        {
                            startLevel.Unload();
                        }
                    }
                }
                else if (Server.AutoLoad)
                {
                    Command.all.Find("load").Use(p, message);
                    foundLevel = Level.Find(message);
                    if (foundLevel != null)
                    {
                        Use(p, message);
                    }
                }
                else
                {
                    Player.SendMessage(p, "There is no level \"" + message + "\" loaded.");
                }

                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
            catch (Exception e) { Server.ErrorLog(e); }
        }
Ejemplo n.º 7
0
        public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
        {
            byte by = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, by);
            Pos bp = (Pos)p.blockchangeObject;

            double a = Math.Sin(((double)(128 - p.rot[0]) / 256) * 2 * Math.PI);
            double b = Math.Cos(((double)(128 - p.rot[0]) / 256) * 2 * Math.PI);
            double c = Math.Cos(((double)(p.rot[1] + 64) / 256) * 2 * Math.PI);

            double bigDiag = Math.Sqrt(Math.Sqrt(p.level.width * p.level.width + p.level.height * p.level.height) + p.level.depth * p.level.depth + p.level.width * p.level.width);

            List<CatchPos> previous = new List<CatchPos>();
            List<CatchPos> allBlocks = new List<CatchPos>();
            CatchPos pos;

            if (p.modeType != Block.air)
                type = p.modeType;

            Thread gunThread = new Thread(new ThreadStart(delegate
            {
                ushort startX = (ushort)(p.pos[0] / 32);
                ushort startY = (ushort)(p.pos[1] / 32);
                ushort startZ = (ushort)(p.pos[2] / 32);

                pos.x = (ushort)Math.Round(startX + (double)(a * 3));
                pos.y = (ushort)Math.Round(startY + (double)(c * 3));
                pos.z = (ushort)Math.Round(startZ + (double)(b * 3));

                for (double t = 4; bigDiag > t; t++)
                {
                    pos.x = (ushort)Math.Round(startX + (double)(a * t));
                    pos.y = (ushort)Math.Round(startY + (double)(c * t));
                    pos.z = (ushort)Math.Round(startZ + (double)(b * t));

                    by = p.level.GetTile(pos.x, pos.y, pos.z);

                    if (by != Block.air && !allBlocks.Contains(pos))
                    {
                        if (p.level.physics < 2 || bp.ending <= 0)
                        {
                            break;
                        }
                        else
                        {
                            if (bp.ending == 1)
                            {
                                if ((!Block.LavaKill(by) && !Block.NeedRestart(by)) && by != Block.glass)
                                {
                                    break;
                                }
                            }
                            else if (p.level.physics >= 3)
                            {
                                if (by != Block.glass)
                                {
                                    p.level.MakeExplosion(pos.x, pos.y, pos.z, 1);
                                    break;
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                    }

                    p.level.Blockchange(pos.x, pos.y, pos.z, type);
                    previous.Add(pos);
                    allBlocks.Add(pos);

                    bool comeOut = false;
                    foreach (Player pl in Player.players)
                    {
                        if (pl.level == p.level)
                        {
                            if ((ushort)(pl.pos[0] / 32) == pos.x || (ushort)(pl.pos[0] / 32  + 1) == pos.x || (ushort)(pl.pos[0] / 32 - 1) == pos.x)
                            {
                                if ((ushort)(pl.pos[1] / 32) == pos.y || (ushort)(pl.pos[1] / 32 + 1) == pos.y || (ushort)(pl.pos[1] / 32 - 1) == pos.y)
                                {
                                    if ((ushort)(pl.pos[2] / 32) == pos.z || (ushort)(pl.pos[2] / 32 + 1) == pos.z || (ushort)(pl.pos[2] / 32 - 1) == pos.z)
                                    {
                                        if (p.level.ctfmode && !p.level.ctfgame.friendlyfire && p.team == pl.team)
                                        {
                                            comeOut = true;
                                            break;
                                        }
                                        if (p.level.ctfmode)
                                        {
                                            pl.health = pl.health - 25;
                                            if (pl.health > 0)
                                            {
                                                pl.SendMessage("You have been shot!  You have &c" + pl.health + Server.DefaultColor + " health remaining.");
                                                comeOut = true;
                                                break;
                                            }
                                        }

                                        if (p.level.physics >= 3 && bp.ending >= 2)
                                            pl.HandleDeath(Block.stone, " was blown up by " + p.color + p.name, true);
                                        else
                                            pl.HandleDeath(Block.stone, " was shot by " + p.color + p.name);
                                        comeOut = true;

                                    }
                                }
                            }
                        }
                    }
                    if (comeOut) break;

                    if (t > 12 && bp.ending != 3)
                    {
                        pos = previous[0];
                        p.level.Blockchange(pos.x, pos.y, pos.z, Block.air);
                        previous.Remove(pos);
                    }

                    if (bp.ending != 3) Thread.Sleep(20);
                }

                if (bp.ending == -1)
                    try
                    {
                        unchecked { p.SendPos((byte)-1, (ushort)(previous[previous.Count - 3].x * 32), (ushort)(previous[previous.Count - 3].y * 32 + 32), (ushort)(previous[previous.Count - 3].z * 32), p.rot[0], p.rot[1]); }
                    } catch { }
                if (bp.ending == 3) Thread.Sleep(400);

                foreach (CatchPos pos1 in previous)
                {
                    p.level.Blockchange(pos1.x, pos1.y, pos1.z, Block.air);
                    if (bp.ending != 3) Thread.Sleep(20);
                }
            }));
            gunThread.Start();
        }
Ejemplo n.º 8
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                message = p.name;
            }

            if (message.ToLower() == "all")
            {
                if (p.group.Permission < LevelPermission.Operator)
                {
                    Player.SendMessage(p, "Reserved for OP+"); return;
                }

                foreach (Player who in Player.players)
                {
                    if (who.level == p.level)
                    {
                        who.Loading = true;
                        foreach (Player pl in Player.players)
                        {
                            if (who.level == pl.level && who != pl)
                            {
                                who.SendDie(pl.id);
                            }
                        }
                        foreach (PlayerBot b in PlayerBot.playerbots)
                        {
                            if (who.level == b.level)
                            {
                                who.SendDie(b.id);
                            }
                        }

                        Player.GlobalDie(who, true);
                        who.SendUserMOTD(); who.SendMap();

                        ushort x = (ushort)((0.5 + who.level.spawnx) * 32);
                        ushort y = (ushort)((1 + who.level.spawny) * 32);
                        ushort z = (ushort)((0.5 + who.level.spawnz) * 32);

                        if (!who.hidden)
                        {
                            Player.GlobalSpawn(who, x, y, z, who.level.rotx, who.level.roty, true);
                        }
                        else
                        {
                            unchecked { who.SendPos((byte)-1, x, y, z, who.level.rotx, who.level.roty); }
                        }

                        foreach (Player pl in Player.players)
                        {
                            if (pl.level == who.level && who != pl && !pl.hidden)
                            {
                                who.SendSpawn(pl.id, pl.color + pl.name, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1]);
                            }
                        }

                        foreach (PlayerBot b in PlayerBot.playerbots)
                        {
                            if (b.level == who.level)
                            {
                                who.SendSpawn(b.id, b.color + b.name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]);
                            }
                        }

                        who.Loading = false;

                        who.SendMessage("&bMap reloaded by " + p.name);
                        Player.SendMessage(p, "&4Finished reloading for " + who.name);

                        /*
                         * foreach (Player pl in Player.players) if (who.level == pl.level && who != pl) who.SendDie(pl.id);
                         * foreach (PlayerBot b in PlayerBot.playerbots) if (who.level == b.level) who.SendDie(b.id);
                         * Player.GlobalDie(who, true);
                         *
                         * who.SendMap();
                         *
                         * ushort x = (ushort)((0.5 + who.level.spawnx) * 32);
                         * ushort y = (ushort)((1 + who.level.spawny) * 32);
                         * ushort z = (ushort)((0.5 + who.level.spawnz) * 32);
                         *
                         * Player.GlobalSpawn(who, x, y, z, who.level.rotx, who.level.roty, true);
                         *
                         * foreach (Player pl in Player.players)
                         *  if (pl.level == who.level && who != pl && !pl.hidden)
                         *      who.SendSpawn(pl.id, pl.color + pl.name, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1]);
                         *
                         * foreach (PlayerBot b in PlayerBot.playerbots)
                         *  if (b.level == who.level)
                         *      who.SendSpawn(b.id, b.color + b.name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]);
                         *
                         * who.SendMessage("Map reloaded.");
                         */
                    }
                }

                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
            else
            {
                Player who = Player.Find(message);
                if (who == null)
                {
                    Player.SendMessage(p, "Could not find player."); return;
                }
                else if (who.group.Permission > p.group.Permission && p != who)
                {
                    Player.SendMessage(p, "Cannot reload the map of someone higher than you."); return;
                }

                who.Loading = true;
                foreach (Player pl in Player.players)
                {
                    if (who.level == pl.level && who != pl)
                    {
                        who.SendDie(pl.id);
                    }
                }
                foreach (PlayerBot b in PlayerBot.playerbots)
                {
                    if (who.level == b.level)
                    {
                        who.SendDie(b.id);
                    }
                }

                Player.GlobalDie(who, true);
                who.SendUserMOTD(); who.SendMap();

                ushort x = (ushort)((0.5 + who.level.spawnx) * 32);
                ushort y = (ushort)((1 + who.level.spawny) * 32);
                ushort z = (ushort)((0.5 + who.level.spawnz) * 32);

                if (!who.hidden)
                {
                    Player.GlobalSpawn(who, x, y, z, who.level.rotx, who.level.roty, true);
                }
                else
                {
                    unchecked { who.SendPos((byte)-1, x, y, z, who.level.rotx, who.level.roty); }
                }

                foreach (Player pl in Player.players)
                {
                    if (pl.level == who.level && who != pl && !pl.hidden)
                    {
                        who.SendSpawn(pl.id, pl.color + pl.name, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1]);
                    }
                }

                foreach (PlayerBot b in PlayerBot.playerbots)
                {
                    if (b.level == who.level)
                    {
                        who.SendSpawn(b.id, b.color + b.name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]);
                    }
                }

                who.Loading = false;
                GC.Collect();
                GC.WaitForPendingFinalizers();

                who.SendMessage("&bMap reloaded by " + p.name);
                Player.SendMessage(p, "&4Finished reloading for " + who.name);

                /*
                 * foreach (Player pl in Player.players) if (who.level == pl.level && who != pl) who.SendDie(pl.id);
                 * foreach (PlayerBot b in PlayerBot.playerbots) if (who.level == b.level) who.SendDie(b.id);
                 * Player.GlobalDie(who, true);
                 *
                 * who.SendMap();
                 *
                 * ushort x = (ushort)((0.5 + who.level.spawnx) * 32);
                 * ushort y = (ushort)((1 + who.level.spawny) * 32);
                 * ushort z = (ushort)((0.5 + who.level.spawnz) * 32);
                 *
                 * Player.GlobalSpawn(who, x, y, z, who.level.rotx, who.level.roty, true);
                 *
                 * foreach (Player pl in Player.players)
                 *  if (pl.level == who.level && who != pl && !pl.hidden)
                 *      who.SendSpawn(pl.id, pl.color + pl.name, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1]);
                 *
                 * foreach (PlayerBot b in PlayerBot.playerbots)
                 *  if (b.level == who.level)
                 *      who.SendSpawn(b.id, b.color + b.name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]);
                 *
                 * who.SendMessage("Map reloaded.");
                 */
            }
        }
Ejemplo n.º 9
0
        public override void Use(Player p, string message)
        {
            p.onTrain = !p.onTrain;

            if (!p.onTrain)
            {
                return;
            }

            Thread trainThread = new Thread(new ThreadStart(delegate
            {
                while (p.onTrain)
                {
                    Thread.Sleep(3);

                    ushort x = (ushort)(p.pos[0] / 32);
                    ushort y = (ushort)(p.pos[1] / 32);
                    ushort z = (ushort)(p.pos[2] / 32);

                    for (ushort xx = (ushort)(x - 1); xx <= x + 1; xx++)
                    {
                        for (ushort yy = (ushort)(y - 1); yy <= y + 1; yy++)
                        {
                            for (ushort zz = (ushort)(z - 1); zz <= z + 1; zz++)
                            {
                                if (p.level.GetTile(xx, yy, zz) == Block.train)
                                {
                                    p.invincible = true; p.trainGrab = true;
                                    byte newY    = 0;

                                    if (y - yy == -1)
                                    {
                                        newY = 240;
                                    }
                                    else if (y - yy == 0)
                                    {
                                        newY = 0;
                                    }
                                    else
                                    {
                                        newY = 8;
                                    }

                                    unchecked
                                    {
                                        if (x - xx == -1)
                                        {
                                            if (z - zz == -1)
                                            {
                                                p.SendPos((byte)-1, (ushort)(xx * 32 + 16), (ushort)((yy + 1) * 32 - 2), (ushort)(zz * 32 + 16), (byte)96, newY);
                                            }
                                            else if (z - zz == 0)
                                            {
                                                p.SendPos((byte)-1, (ushort)(xx * 32 + 16), (ushort)((yy + 1) * 32 - 2), (ushort)(zz * 32 + 16), (byte)64, newY);
                                            }
                                            else
                                            {
                                                p.SendPos((byte)-1, (ushort)(xx * 32 + 16), (ushort)((yy + 1) * 32 - 2), (ushort)(zz * 32 + 16), (byte)32, newY);
                                            }
                                        }
                                        else if (x - xx == 0)
                                        {
                                            if (z - zz == -1)
                                            {
                                                p.SendPos((byte)-1, (ushort)(xx * 32 + 16), (ushort)((yy + 1) * 32 - 2), (ushort)(zz * 32 + 16), (byte)128, newY);
                                            }
                                            else if (z - zz == 0)
                                            {
                                            }
                                            else
                                            {
                                                p.SendPos((byte)-1, (ushort)(xx * 32 + 16), (ushort)((yy + 1) * 32 - 2), (ushort)(zz * 32 + 16), (byte)0, newY);
                                            }
                                        }
                                        else
                                        if (z - zz == -1)
                                        {
                                            p.SendPos((byte)-1, (ushort)(xx * 32 + 16), (ushort)((yy + 1) * 32 - 2), (ushort)(zz * 32 + 16), (byte)160, newY);
                                        }
                                        else if (z - zz == 0)
                                        {
                                            p.SendPos((byte)-1, (ushort)(xx * 32 + 16), (ushort)((yy + 1) * 32 - 2), (ushort)(zz * 32 + 16), (byte)192, newY);
                                        }
                                        else
                                        {
                                            p.SendPos((byte)-1, (ushort)(xx * 32 + 16), (ushort)((yy + 1) * 32 - 2), (ushort)(zz * 32 + 16), (byte)224, newY);
                                        }
                                    }
                                    goto skip;
                                }
                            }
                        }
                    }

                    Thread.Sleep(3);
                    p.invincible = false;
                    p.trainGrab  = false;
                    skip:;
                }

                Player.SendMessage(p, "Dismounted");
                Thread.Sleep(1000);
                p.invincible = false;
                p.trainGrab  = false;
            }));

            trainThread.Start();
            Player.SendMessage(p, "Stand near a train to mount it");
        }
Ejemplo n.º 10
0
 public override void Use(Player p, string message)
 {
     if (message == "")
     {
         Command.all.Find("spawn");
         return;
     }
     string[] split = message.Split(' ');
     if (split.Length <= 1)
     {
         Player who = Player.Find(message);
         if (who == null || (who.hidden && p.group.Permission < LevelPermission.Admin)) { Player.SendMessage(p, "There is no player \"" + message + "\"!"); return; }
         if (p.level != who.level)
         {
             if (who.level.name.Contains("cMuseum"))
             {
                 Player.SendMessage(p, "Player \"" + message + "\" is in a museum!");
                 return;
             }
             if (who.level.locked)
             {
                 Player.SendMessage(p, "Player \"" + message + "\" is in a locked level!");
                 return;
             }
             else
             {
                 Command.all.Find("goto").Use(p, who.level.name);
             }
         }
         if (p.level == who.level)
         {
             if (who.Loading)
             {
                 Player.SendMessage(p, "Waiting for " + who.color + who.name + Server.DefaultColor + " to spawn...");
                 while (who.Loading) { }
             }
             while (p.Loading) { }  //Wait for player to spawn in new map
             unchecked { p.SendPos((byte)-1, who.pos[0], who.pos[1], who.pos[2], who.rot[0], 0); }
         }
         return;
     }
     if (split.Length <= 2)
     {
         ushort x;
         ushort y;
         ushort z;
         try // X (width)
         {
             x = Convert.ToUInt16(split[0]);
         }
         catch { Player.SendMessage(p, "Invalid coordinates!"); return; }
         try // Y (height)
         {
             y = Convert.ToUInt16(split[1]);
         }
         catch { Player.SendMessage(p, "Invalid coordinates!"); return; }
         try // Z (depth)
         {
             z = Convert.ToUInt16(split[2]);
         }
         catch { Player.SendMessage(p, "Invalid coordinates!"); return; }
         if ((x > p.level.width) || (y > p.level.height) || (z > p.level.depth)) { Player.SendMessage(p, "Invalid coordinates!"); return; }
         unchecked { p.SendPos((byte)-1, x, y, z, p.rot[0], 0); }
     }
 }
Ejemplo n.º 11
0
        public override void Use(Player p, string message)
        {
            if (message == "") message = "list";

            string[] parameters = message.Split(' ');

            if (parameters[0].ToLower() == "list")
            {
                if (parameters.Length > 1)
                {
                    int pageNum, currentNum;
                    try
                    {
                        pageNum = int.Parse(parameters[1]) * 10; currentNum = pageNum - 10;
                    }
                    catch { Help(p); return; }

                    if (currentNum < 0) { Player.SendMessage(p, "Must be greater than 0"); return; }
                    if (pageNum > p.level.ZoneList.Count) pageNum = p.level.ZoneList.Count;
                    if (currentNum > p.level.ZoneList.Count) { Player.SendMessage(p, "No Zones beyond number " + (p.level.ZoneList.Count - 1)); return; }

                    Player.SendMessage(p, "Zones (" + currentNum + " to " + (pageNum - 1) + "):");
                    for (int i = currentNum; i < pageNum; i++)
                    {
                        Level.Zone zone = p.level.ZoneList[i];
                        Player.SendMessage(p, "&c" + i + " &b(" +
                            zone.smallX + "-" + zone.bigX + ", " +
                            zone.smallY + "-" + zone.bigY + ", " +
                            zone.smallZ + "-" + zone.bigZ + ") &f" +
                            zone.Owner);
                    }
                }
                else
                {
                    for (int i = 0; i < p.level.ZoneList.Count; i++)
                    {
                        Level.Zone zone = p.level.ZoneList[i];
                        Player.SendMessage(p, "&c" + i + " &b(" +
                            zone.smallX + "-" + zone.bigX + ", " +
                            zone.smallY + "-" + zone.bigY + ", " +
                            zone.smallZ + "-" + zone.bigZ + ") &f" +
                            zone.Owner);
                    }
                    Player.SendMessage(p, "For a more structured list, use /tpzone list <1/2/3/..>");
                }
            }
            else
            {
                int zoneID;
                try
                {
                    zoneID = int.Parse(message);
                }
                catch { Help(p); return; }

                if (zoneID < 0 || zoneID > p.level.ZoneList.Count)
                {
                    Player.SendMessage(p, "This zone doesn't exist");
                    return;
                }

                Level.Zone zone = p.level.ZoneList[zoneID];
                unchecked { p.SendPos((byte)-1, (ushort)(zone.bigX * 32 + 16), (ushort)(zone.bigY * 32 + 32), (ushort)(zone.bigZ * 32 + 16), p.rot[0], p.rot[1]); }

                Player.SendMessage(p, "Teleported to zone &c" + zoneID + " &b(" +
                    zone.bigX + ", " + zone.bigY + ", " + zone.bigZ + ") &f" +
                    zone.Owner);
            }
        }