protected void LeaveCommand(CommandArgs args) { TPPlayer player = args.Player; foreach (Channel c in Channels) { if (c.ContainsPlayer(player)) { c.Leave(player); player.SendInfoMessage("Channels: Channel left"); return; } } player.SendErrorMessage("Channels: You're not in any channel!"); }
protected void JoinCommand(CommandArgs args) { TPPlayer player = args.Player; if (args.Parameters.Count == 1) { string cname = args.Parameters[0]; if (Manager.Contains(cname)) { foreach (Channel c in Channels) { if (c.ContainsPlayer(player)) { c.Leave(player); } } foreach (Channel c in Channels) { if (c.Name == cname) { c.Join(player); player.SendInfoMessage(String.Format("Channels: You've entered {0} channel", cname)); break; } } } else { player.SendErrorMessage(String.Format("Channels: {0} doesn't exists!", cname)); } } else { player.SendErrorMessage("Channels: Missing or too much arguments!"); } }
protected void ChannelCommand(CommandArgs args) { TPPlayer player = args.Player; if (args.Parameters.Count > 1) { if ((player.Group.ContainsGroup("admin") || player.Group.ContainsGroup("superadmin")) && player.IsLoggedIn) { string pram = args.Parameters[0]; if (pram == "add") { //adding channel string cname = args.Parameters[1]; if (Manager.Contains(cname)) { player.SendErrorMessage(String.Format("Channels: {0} already exists!")); } else { Channel c; if (args.Parameters.Count == 5) { //with custom color byte r = 0; byte g = 0; byte b = 0; byte.TryParse(args.Parameters[2], out r); byte.TryParse(args.Parameters[3], out g); byte.TryParse(args.Parameters[4], out b); c = new Channel(cname, r, g, b); } else { c = new Channel(cname); } Manager.Add(c); Channels.Add(c); player.SendInfoMessage(String.Format("Channels: {0} channel added with success!", cname)); } } else if (pram == "del") { //deleting channel string cname = args.Parameters[1]; Channel c = RemoveChannel(cname); if (c != null) { Manager.Remove(cname); player.SendInfoMessage(String.Format("Channels: {0} channel removed!", cname)); } else { player.SendErrorMessage("Channels: This channel doesn't exists!"); } } else { player.SendErrorMessage("Channels: Invalid command!"); } } else { player.SendErrorMessage("Channels: You don't have the right to do this!"); } } else if (args.Parameters.Count == 1 && args.Parameters[0] == "list") { //listing channels player.SendInfoMessage("Channels: Listing channels"); foreach (Channel c in Channels) { player.SendInfoMessage(String.Format("{0} : {1}", c.Name, c.Count)); } player.SendInfoMessage(String.Format("{0} channel(s)", Channels.Count)); } else { player.SendErrorMessage("Channels: Invalid command"); } }