Example #1
0
        private void MessageAllCommand(CommandArgs args)
        {
            TPPlayer player = args.Player;

            if (player.IsLoggedIn)
            {
                FriendList fl = FriendsList.GetListByUserID(player.UserID);

                if (fl != null)
                {
                    string message = "";

                    for (int i = 0; i < args.Parameters.Count; i++)
                    {
                        message += args.Parameters[i] + " ";
                    }

                    foreach (FUser fu in fl.Friends)
                    {
                        TPPlayer pdest = GetOnlinePlayerById(fu.ID);

                        if (pdest != null)
                        {
                            pdest.SendMessage(String.Format("{0}: {1}", player.UserAccountName, message), TextColor);
                        }
                    }

                    player.SendMessage(String.Format("{0}: {1}", "To All", message), TextColor);
                }
            }
            else
            {
                player.SendErrorMessage("Friends: You're not logged in!");
            }
        }
Example #2
0
        protected void ChannelMessage(CommandArgs args)
        {
            TPPlayer player = args.Player;

            Channel pChannel = null;

            foreach (Channel c in Channels)
            {
                if (c.ContainsPlayer(player))
                {
                    pChannel = c;
                    break;
                }
            }

            if (pChannel == null)
            {
                player.SendErrorMessage("Channels: You're not in a channel!");
            }
            else
            {
                string message = "";

                for (int i = 0; i < args.Parameters.Count; i++)
                {
                    message += args.Parameters[i] + " ";
                }

                pChannel.Send(player, message);
            }
        }
Example #3
0
        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!");
            }
        }
Example #4
0
        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!");
        }
Example #5
0
        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");
            }
        }