コード例 #1
0
ファイル: CmdAward.cs プロジェクト: Benedani/MCGalaxy
        public override void Use(Player p, string message)
        {
            if (message == "" || message.IndexOf(' ') == -1)
            {
                Help(p); return;
            }
            bool take = false;

            if (message.CaselessStarts("give "))
            {
                message = message.Substring(5);
            }
            else if (message.CaselessStarts("take "))
            {
                message = message.Substring(5); take = true;
            }

            string[] args   = message.SplitSpaces(2);
            string   plName = PlayerInfo.FindMatchesPreferOnline(p, args[0]);

            if (plName == null)
            {
                return;
            }

            string award   = args.Length > 1 ? args[1] : "";
            int    matches = 0;

            award = Awards.FindMatches(p, award, out matches);
            if (award == null)
            {
                Player.Message(p, "Use /awards for a list of awards"); return;
            }

            if (!take)
            {
                if (Awards.GiveAward(plName, award))
                {
                    Chat.MessageAll("{0} %Swas awarded: &b{1}",
                                    PlayerInfo.GetColoredName(p, plName), award);
                    Awards.SavePlayers();
                }
                else
                {
                    Player.Message(p, "The player already has that award."); return;
                }
            }
            else
            {
                if (Awards.TakeAward(plName, award))
                {
                    Chat.MessageAll("{0} %Shad their &b{1} %Saward removed",
                                    PlayerInfo.GetColoredName(p, plName), award);
                    Awards.SavePlayers();
                }
                else
                {
                    Player.Message(p, "The player didn't have the award you tried to take"); return;
                }
            }
        }