private void FriendCommand(CommandArgs args) { //Sub-command //add : add a friend //del : delete a friend //list : list your friend list //help : Send a help message TPPlayer player = args.Player; if (player != null) { if (player.IsLoggedIn) { if (args.Parameters.Count >= 2) { User cu = tPulse.Users.GetUserByID(player.UserID); FriendList fl = GetListOrCreate(cu); string prams = args.Parameters[0]; prams = prams.ToLower(); if (prams == "add") { //Add string adduser = args.Parameters[1]; User u = tPulse.Users.GetUserByName(adduser); if (u == null) { player.SendMessage(String.Format("Friends: {0} doesn't exists !", adduser), TextColor); return; } if (fl.Contains(u.Name)) { player.SendMessage(String.Format("Friends: {0} is already in your friend list", adduser), TextColor); return; } FUser fu = new FUser(u); fl.Friends.Add(fu); player.SendMessage(String.Format("Friends: {0} added!", adduser), TextColor); } else if (prams == "del") { //Delete string remuser = args.Parameters[1]; if (fl.Contains(remuser)) { fl.RemoveUserByName(remuser); player.SendMessage(String.Format("Friends: {0} deleted!", remuser), TextColor); } else { player.SendMessage(String.Format("Friends: {0} is not in your friends list", remuser), TextColor); } } } else if (args.Parameters.Count == 1) { string prams = args.Parameters[0]; if (prams == "help") { SendHelp(player); } else if (prams == "list") { User cu = tPulse.Users.GetUserByID(player.UserID); FriendList fl = GetListOrCreate(cu); player.SendMessage(String.Format("Friends: {0} friend(s) in your list", fl.Friends.Count.ToString()), TextColor); int i = 1; foreach (FUser fu in fl.Friends) { string status = IsUserOnline(fu.ID) ? "Online" : "Offline"; player.SendMessage(String.Format("{0} : {1} : {2}", i.ToString(), fu.Name, status), TextColor); i++; } } } else { player.SendMessage("Friends: Missing arguments", TextColor); } } else { player.SendMessage("Friends: You can't use friend list, because you're not logged!", TextColor); } } }