public override void Execute(ConsoleSystem.Arg Arguments, string[] ChatArguments) { if (ChatArguments != null) { string name = ""; for (int i = 0; i < ChatArguments.Length; i++) { name = name + ChatArguments[i] + " "; } name = name.Trim(); if (name != null) { PlayerClient client = null; try { client = EnumerableToArray.ToArray <PlayerClient>(PlayerClient.FindAllWithName(name, StringComparison.CurrentCultureIgnoreCase))[0]; } catch (Exception ex) { client = null; Logger.LogException(ex); } FriendsCommand command = (FriendsCommand)ChatCommand.GetCommand("friends"); FriendList list = (FriendList)command.GetFriendsLists()[Arguments.argUser.userID]; if (client == null) { Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "No player found with the name: " + name); } else if (Arguments.argUser.userID == client.userID) { Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "You can't add yourself as a friend!"); } else { if (list != null) { if (list.isFriendWith(client.userID)) { Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "You are already friend with " + client.netUser.displayName + "."); return; } } else { list = new FriendList(); } list.AddFriend(client.netUser.displayName, client.userID); command.GetFriendsLists()[Arguments.argUser.userID] = list; Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "You have added " + client.netUser.displayName + " to your friend list."); } } } else { Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "Friends Management Usage: /addfriend \"playerName\""); } }
public override void Execute(ConsoleSystem.Arg Arguments, string[] ChatArguments) { if (ChatArguments != null) { string name = ""; for (int i = 0; i < ChatArguments.Length; i++) { name = name + ChatArguments[i] + " "; } name = name.Trim(); if (name != null) { PlayerClient client = null; try { client = EnumerableToArray.ToArray <PlayerClient>(PlayerClient.FindAllWithName(name, StringComparison.CurrentCultureIgnoreCase))[0]; } catch (Exception ex) { client = null; Logger.LogException(ex); } FriendsCommand command = (FriendsCommand)ChatCommand.GetCommand("friends"); FriendList list = (FriendList)command.GetFriendsLists()[Arguments.argUser.userID]; if (list != null) { string realName; if (client == null) { if (!list.isFriendWith(name)) { Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "You are not friends with " + name); return; } list.RemoveFriend(name); realName = list.GetRealName(name); } else { if (!list.isFriendWith(client.userID)) { Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "You are not friends with " + name); return; } list.RemoveFriend(client.userID); realName = client.netUser.displayName; } Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "You have removed " + realName + " from your friends list."); if (list.HasFriends()) { command.GetFriendsLists()[Arguments.argUser.userID] = list; } else { command.GetFriendsLists().Remove(Arguments.argUser.userID); } } else { Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "You currently have no friends."); } } } else { Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "Friends Management Usage: /unfriend \"playerName\""); } }
public void OutputList(ref ConsoleSystem.Arg arg) { ArrayList list = new ArrayList(); ArrayList list2 = new ArrayList(); foreach (Friend friend in this) { PlayerClient client; try { client = EnumerableToArray.ToArray <PlayerClient>(PlayerClient.FindAllWithString(friend.GetUserID().ToString()))[0]; } catch { list2.Add(friend.GetDisplayName()); continue; } list.Add(client.netUser.displayName + " (Online)"); friend.SetDisplayName(client.netUser.displayName); } if (list.Count > 0) { Util.sayUser(arg.argUser.networkPlayer, Core.Name, string.Concat(new object[] { "You currently have ", list.Count, " friend", (list.Count > 1) ? "s" : "", " online." })); } else { Util.sayUser(arg.argUser.networkPlayer, Core.Name, "None of your friend is playing right now."); } foreach (string str in list2) { list.Add(str); } int num = 0; int num2 = 0; string str2 = ""; foreach (string str3 in list) { num2++; if (num2 >= 60) { num = 0; break; } str2 = str2 + str3 + ", "; if (num == 6) { num = 0; Util.sayUser(arg.argUser.networkPlayer, Core.Name, str2.Substring(0, str2.Length - 3)); str2 = ""; } else { num++; } } if (num != 0) { Util.sayUser(arg.argUser.networkPlayer, Core.Name, str2.Substring(0, str2.Length - 3)); } }