コード例 #1
0
ファイル: TFriends.cs プロジェクト: jordsti/TPulse
        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!");
            }
        }
コード例 #2
0
ファイル: RegionManager.cs プロジェクト: jordsti/TPulse
        public bool HasPermissionToBuildInRegion(TPPlayer ply)
        {
            if (!ply.IsLoggedIn)
            {
                if (!ply.HasBeenNaggedAboutLoggingIn)
                {
                    ply.SendMessage("You must be logged in to take advantage of protected regions.", Color.Red);
                    ply.HasBeenNaggedAboutLoggingIn = true;
                }
                return(false);
            }
            if (!DisableBuild)
            {
                return(true);
            }

            return(AllowedIDs.Contains(ply.UserID) || AllowedGroups.Contains(ply.Group.Name) || Owner == ply.UserAccountName ||
                   ply.Group.HasPermission("manageregion"));
        }
コード例 #3
0
ファイル: TFriends.cs プロジェクト: jordsti/TPulse
        private void PlayerLogin(PlayerLoginEventArgs args)
        {
            FriendList fl = FriendsList.GetListByUserID(args.Player.UserID);

            if (fl == null)
            {
                return;
            }

            foreach (FUser fu in fl.Friends)
            {
                if (IsUserOnline(fu.ID))
                {
                    TPPlayer dplayer = GetOnlinePlayerById(fu.ID);
                    if (dplayer != null)
                    {
                        dplayer.SendMessage(String.Format("{0} just logged in!", args.Player.UserAccountName), TextColor);
                    }
                }
            }
        }
コード例 #4
0
ファイル: RegionManager.cs プロジェクト: jordsti/TPulse
        public bool HasPermissionToBuildInRegion(TPPlayer ply)
        {
            if (!ply.IsLoggedIn)
            {
                if (!ply.HasBeenNaggedAboutLoggingIn)
                {
                    ply.SendMessage("You must be logged in to take advantage of protected regions.", Color.Red);
                    ply.HasBeenNaggedAboutLoggingIn = true;
                }
                return false;
            }
            if (!DisableBuild)
            {
                return true;
            }

            return AllowedIDs.Contains(ply.UserID) || AllowedGroups.Contains(ply.Group.Name) || Owner == ply.UserAccountName ||
                   ply.Group.HasPermission("manageregion");
        }
コード例 #5
0
ファイル: TFriends.cs プロジェクト: jordsti/TPulse
 private void SendHelp(TPPlayer player)
 {
     player.SendMessage("Friends: /friend cmd [args]", TextColor);
     player.SendMessage("Friends: Available commands", TextColor);
     player.SendMessage("Friends: add, del, list, help", TextColor);
 }
コード例 #6
0
ファイル: TFriends.cs プロジェクト: jordsti/TPulse
        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);
                }
            }
        }
コード例 #7
0
ファイル: TFriends.cs プロジェクト: jordsti/TPulse
        private void MessageCommand(CommandArgs args)
        {
            try
            {
                TPPlayer   player = args.Player;
                TPPlayer   dest;
                FriendList fl;
                if (player.IsLoggedIn)
                {
                    fl = FriendsList.GetListByUserID(player.UserID);
                }
                else
                {
                    return;
                }


                if (args.Parameters.Count >= 1)
                {
                    string target  = args.Parameters[0];
                    string message = "";

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

                    if (regexNumber.IsMatch(target))
                    {
                        //Friends number

                        int order = int.Parse(target) - 1;

                        FUser udest = fl.GetUser(order);
                        if (udest != null)
                        {
                            dest = GetOnlinePlayerById(udest.ID);

                            if (dest != null)
                            {
                                dest.SendMessage(String.Format("{0}: {1}", player.UserAccountName, message), TextColor);
                                player.SendMessage(String.Format("To {0}: {1}", dest.UserAccountName, message), TextColor);
                            }
                            else
                            {
                                player.SendMessage("Friends: this friend is not online", TextColor);
                            }
                        }
                        else
                        {
                            player.SendMessage(String.Format("Friends: {0} is not a valid friend id", order.ToString()), TextColor);
                        }
                    }
                    else
                    {
                        string name  = args.Parameters[0];
                        FUser  udest = fl.GetUser(name);
                        if (udest != null)
                        {
                            dest = GetOnlinePlayerById(udest.ID);

                            if (dest != null)
                            {
                                dest.SendMessage(String.Format("{0}: {1}", player.UserAccountName, message), TextColor);
                            }
                            else
                            {
                                player.SendMessage("Friends: this friend is not online", TextColor);
                            }
                        }
                        else
                        {
                            player.SendMessage(String.Format("Friends: {0} is not a valid friend", name), TextColor);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //put this into a log file or just remove it
                //will see
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
                Console.WriteLine(ex.Source);
                Console.WriteLine(ex.TargetSite);
            }
        }