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 (Awards.GiveAward(plName, award)) { Chat.MessageGlobal("{0} %Swas awarded: &b{1}", displayName, award); Awards.SavePlayers(); } else if (plName.CaselessEq(p.name)) { p.Message("You already have that award."); } else { p.Message("{0} %Salready has that award.", displayName); } } else { if (Awards.TakeAward(plName, award)) { Chat.MessageGlobal("{0} %Shad their &b{1} %Saward removed", displayName, award); Awards.SavePlayers(); } 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); } } }
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; } } }