Beispiel #1
0
        public override void Use(Player p, string message, CommandData data)
        {
            string[] args = message.SplitSpaces();
            if (args.Length > 2)
            {
                Help(p); return;
            }
            int    offset = 0;
            string name   = p.name;

            if (args.Length == 2 || (message.Length > 0 && !IsListModifier(args[0])))
            {
                offset = 1;
                name   = PlayerInfo.FindMatchesPreferOnline(p, args[0]);
                if (name == null)
                {
                    return;
                }
            }

            List <Award> awards = AwardsList.Awards;

            if (awards.Count == 0)
            {
                p.Message("This server has no awards yet."); return;
            }

            List <string>           playerAwards = PlayerAwards.Get(name);
            StringFormatter <Award> formatter    = (award) => FormaAward(award, playerAwards);

            string cmd      = name.Length == 0 ? "awards" : "awards " + name;
            string modifier = args.Length > offset ? args[offset] : "";

            p.Message("Awards {0} &Shas:", p.FormatNick(name));
            MultiPageOutput.Output(p, awards, formatter,
                                   cmd, "Awards", modifier, true);
        }
Beispiel #2
0
        public override void Use(Player p, string message, CommandData data)
        {
            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);
            if (args.Length < 2)
            {
                Help(p); return;
            }
            string plName = PlayerInfo.FindMatchesPreferOnline(p, args[0]);

            if (plName == null)
            {
                return;
            }
            string award = Matcher.FindAwards(p, args[1]);

            if (award == null)
            {
                p.Message("Use &T/Awards &Sfor a list of awards"); return;
            }

            string displayName = p.FormatNick(plName);

            if (!take)
            {
                if (PlayerAwards.Give(plName, award))
                {
                    Chat.MessageGlobal("{0} &Swas awarded: &b{1}", displayName, award);
                    PlayerAwards.Save();
                }
                else if (plName.CaselessEq(p.name))
                {
                    p.Message("You already have that award.");
                }
                else
                {
                    p.Message("{0} &Salready has that award.", displayName);
                }
            }
            else
            {
                if (PlayerAwards.Take(plName, award))
                {
                    Chat.MessageGlobal("{0} &Shad their &b{1} &Saward removed", displayName, award);
                    PlayerAwards.Save();
                }
                else if (plName.CaselessEq(p.name))
                {
                    p.Message("You did not have that award to begin with.");
                }
                else
                {
                    p.Message("{0} &Sdid not have that award to begin with.", displayName);
                }
            }
        }