コード例 #1
0
        public static void HWInfo_OnTarget(Mobile from, object obj)
        {
            if (obj is Mobile && ((Mobile)obj).Player)
            {
                Mobile  m    = (Mobile)obj;
                Account acct = m.Account as Account;

                string hwInfoTag = acct.GetTag(HardwareInfo.AccountTagName);
                if (hwInfoTag != null)
                {
                    // check it against all other accounts:
                    string[] hwInfoTags = hwInfoTag.Split('|');
                    foreach (string tag in hwInfoTags)
                    {
                        int tagNumber = -1;
                        if (tag == String.Empty)
                        {
                            continue;
                        }
                        try
                        {
                            tagNumber = int.Parse(tag);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine("HWInfo error with tag " + tag + ": " + e.Message);
                            Console.WriteLine(e.StackTrace);
                            continue;
                        }
                        foreach (Account account in Accounts.GetAccounts())
                        {
                            if (HasHWInfoInstance(account, tagNumber))
                            {
                                from.SendMessage(account.Username + " " + tagNumber);
                            }
                        }
                    }
                }

                if (acct != null)
                {
                    HardwareInfo hwInfo = acct.HardwareInfo;

                    if (hwInfo != null)
                    {
                        CommandLogging.WriteLine(from, "{0} {1} viewing hardware info of {2}", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(m));
                    }

                    if (hwInfo != null)
                    {
                        from.SendGump(new Gumps.PropertiesGump(from, hwInfo));
                    }
                    else
                    {
                        from.SendMessage("No hardware information for that account was found.");
                    }
                }
                else
                {
                    from.SendMessage("No account has been attached to that player.");
                }
            }
            else
            {
                from.BeginTarget(-1, false, TargetFlags.None, new TargetCallback(HWInfo_OnTarget));
                from.SendMessage("That is not a player. Try again.");
            }
        }
コード例 #2
0
            private static void TAFTarget(Mobile from, object target)
            {
                if (from == null)
                {
                    return;
                }

                string initialText = "";

                if (target is PlayerMobile)
                {
                    Mobile    friend     = (Mobile)target;
                    Account   fracct     = (Account)friend.Account;
                    ArrayList tafip_List = new ArrayList(fracct.LoginIPs);

                    Account      acct    = (Account)from.Account;
                    ArrayList    ip_List = new ArrayList(acct.LoginIPs);
                    PlayerMobile pm      = from as PlayerMobile;


                    bool toldu = Convert.ToBoolean(acct.GetTag("ToldAFriend"));

                    if (fracct == acct)
                    {
                        initialText = "You can't be your own referrer!";
                    }
                    else
                    {
                        bool uniqueIP = true;

                        foreach (object t in ip_List)
                        {
                            if (tafip_List.Contains(t))
                            {
                                uniqueIP = false;
                            }
                        }

                        XmlReferralRewards re =
                            (XmlReferralRewards)XmlAttach.FindAttachment(friend, typeof(XmlReferralRewards));
                        XmlReferralRewards me =
                            (XmlReferralRewards)XmlAttach.FindAttachment(from, typeof(XmlReferralRewards));

                        //We wrote the method below to prevent players from referring multiple accounts of the same friend.
                        if (uniqueIP)
                        {
                            if (pm != null)
                            {
                                if (me != null)
                                {
                                    if (me.ReferredList.Any(tafip_List.Contains))
                                    {
                                        @from.SendMessage("You've already referred someone that uses their IP address.");
                                        return;
                                    }
                                }
                            }

                            if (!toldu)
                            {
                                initialText = String.Format("{0} marked as referrer.", friend.Name);

                                if (pm != null && me != null)
                                {
                                    foreach (IPAddress ip in tafip_List)
                                    {
                                        me.ReferredList.Add(ip);
                                    }
                                }

                                if (re != null && me != null)
                                {
                                    re.PointsAvailable++;
                                    me.PointsAvailable++;
                                    friend.SendMessage(
                                        "{0} has just marked you as their referrer.  A referral point has been added to your account.  You may spend these by using the [referralrewards command.",
                                        from.Name);
                                    from.SendMessage("You were given a bonus referral point for marking your referrer!");
                                }
                                else
                                {
                                    friend.SendMessage(39, "You are not eligable for referral rewards on {0}.",
                                                       TAFShardName);
                                }

                                acct.SetTag("ToldAFriend", "true");
                                acct.SetTag("Referrer", fracct.ToString());
                            }
                            else
                            {
                                from.SendMessage("You have already set a referrer.");
                                return;
                            }
                        }
                        else
                        {
                            from.SendMessage("You can't refer another account you own.");
                            return;
                        }
                    }
                }
                else
                {
                    initialText = "Please select a player character.";
                }
                from.SendGump(new TAFGump(from, initialText));
            }
コード例 #3
0
        private static void TAFLogin(LoginEventArgs args)
        {
            Mobile m = args.Mobile;

            m.SendMessage(String.Format("Your friend will receive a reward for referring you to {0} next time (s)he logs in.", TAFShardName));
            Account ac         = (Account)m.Account;
            bool    toldfriend = ToldAFriend(m);
            bool    gotfriend  = GotAFriend(m);

            if (ac.Created >= age)
            {
                if (!toldfriend)
                {
                    m.SendGump(new TAFGump(m));
                }
            }
            else if (toldfriend)
            {
                string  friend     = ac.GetTag("Referrer");
                Account friendacct = Accounts.GetAccount(friend) as Account;
                if (friendacct == null)
                {
                    ac.RemoveTag("Referrer");
                }
                else
                {
                    if (ac.LastLogin > mindate && friendacct.LastLogin > mindate && ac.TotalGameTime >= RewardTime && friendacct.TotalGameTime >= RewardTime)
                    {
                        //m.SendMessage( String.Format( "Your friend will receive a reward for referring you to {0} next time (s)he logs in.", TAFShardName ) );
                        m.SendMessage(String.Format("You receive a reward for your loyalty to {0}.", TAFShardName));
                        m.AddToBackpack(new PetBondingDeed());
                        m.AddToBackpack(new ReferrerReward());
                        if (Convert.ToBoolean(ac.GetTag("GotAFriend")))
                        {
                            string friends = ac.GetTag("GotFriend") + "," + ac.ToString();
                            friendacct.SetTag("GotFriend", friends);
                        }
                        else
                        {
                            friendacct.SetTag("GotAFriend", "true");
                            friendacct.SetTag("GotFriend", ac.ToString());
                        }
                        ac.RemoveTag("Referrer");
                        ac.RemoveTag("ToldAFriend");
                    }
                }
            }
            else if (gotfriend)
            {
                string   friend  = ac.GetTag("GotFriend");
                string[] friends = friend.Split(',');
                for (int i = 0; i < friends.Length; ++i)
                {
                    m.SendMessage(String.Format("You receive a reward and a referral token for referring one of your friends to {0}.", TAFShardName));
                    m.AddToBackpack(new PetBondingDeed());
                    m.AddToBackpack(new ReferrerReward());
                }
                ac.RemoveTag("GotAFriend");
                ac.RemoveTag("GotFriend");
            }
        }