예제 #1
0
        public static void Base(Player p, string message, byte newrank)
        {
            if (message.Trim().Equals(""))
            {
                p.SendMessage(0xFF, "No player specified");
                return;
            }

            Player pl = uMiner.Player.FindPlayer(p, message, false);
            if (pl != null)
            {
                if (pl.username.Equals(p.username))
                {
                    p.SendMessage(0xFF, "You can't change your own rank!");
                }
                if (pl.rank < newrank || p.rank > pl.rank || p.username.Equals("[console]"))
                {
                    byte oldRank = pl.rank;
                    pl.rank = newrank;
                    Program.server.playerRanksDict[pl.username.ToLower()] = pl.rank;
                    Program.server.saveRanks();

                    if (newrank == 0)
                    {
                        pl.prefix = "[:(]";
                    }
                    else if (newrank < Rank.RankLevel("operator"))
                    {
                        pl.prefix = "";
                    }
                    else if (newrank == Rank.RankLevel("operator"))
                    {
                        pl.prefix = "+";
                    }
                    else if (newrank == Rank.RankLevel("owner"))
                    {
                        pl.prefix = "@";
                    }

                    //Clear the player's binding as a safeguard
                    pl.binding = Bindings.None;

                    //If the person was OP before, disable adminium editing
                    //Vice versa as well
                    if (oldRank >= Rank.RankLevel("operator") && newrank < Rank.RankLevel("operator"))
                    {
                        Packet deop = new Packet(2);
                        deop.Append((byte)ServerPacket.RankUpdate);
                        deop.Append((byte)0x0);
                        pl.SendPacket(deop);
                    }
                    else if (oldRank < Rank.RankLevel("operator") && newrank >= Rank.RankLevel("operator"))
                    {
                        Packet deop = new Packet(2);
                        deop.Append((byte)ServerPacket.RankUpdate);
                        deop.Append((byte)0x64);
                        pl.SendPacket(deop);
                    }

                    //Despawn and respawn player
                    Packet despawn = new Packet(2);
                    despawn.Append((byte)ServerPacket.PlayerDie);
                    despawn.Append(pl.id);
                    foreach (Player ply in Program.server.playerlist)
                    {
                        if (ply != null && ply != pl && ply.loggedIn && !ply.disconnected)
                        {
                            ply.SendPacket(despawn);
                        }
                    }
                    uMiner.Player.GlobalSpawnPlayer(pl);
                    uMiner.Player.GlobalMessage(p.GetFormattedName() + "&e set " + pl.GetFormattedName() + "&e's rank to " + Rank.GetColor(newrank) + Rank.RankName(newrank) + "&e");
                }
                else
                {
                    p.SendMessage(0xFF, "Player " + pl.GetFormattedName() + "&e cannot have rank set to " + Rank.GetColor(newrank) + Rank.RankName(newrank));
                }
                return;
            }
        }