Esempio n. 1
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); }
        }
Esempio n. 2
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); }
        }
Esempio n. 3
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.");
                 */
            }
        }