I've set my Kudos to be added to a players Bankbox every 30 mins through a reward deed. My problem is if a player is afk and allows more than 1 deed to be added to their bank the deeds stack though I have them set to be stackable = false. How can i fix this? Here's the script:
Code:
//   ___|========================|___
//   \  |  Written by Felladrin  |  /   [Kudos - Exchangeable Game Time Reward] - Current version: 1.3 (September 10, 2013)
//    > |       July 2013        | <
//   /__|========================|__\   Description: An item given to players for each period of time they stay online.

using System;
using Server.Mobiles;
using Server.Network;

namespace Server.Custom.GameTimeReward
{
    public class KudosTimer : Timer
    {
        public static class Config
        {
            public static int MinutesOnline = 30;                            // Every X minutes we give kudos to all players online.
            public static bool DropOnBank = true;                           // Should we place the kudos on character's bankbox (true) or backpack (false)?
            public static AccessLevel MaxAccessLevel = AccessLevel.Player;  // Any character with this access and below receives kudos.
        }

        public static void Initialize()
        {
            new KudosTimer().Start();
        }

        public KudosTimer() : base(TimeSpan.Zero, TimeSpan.FromMinutes(Config.MinutesOnline))
        {
            Priority = TimerPriority.OneMinute;
        }

        protected override void OnTick()
        {
            foreach (NetState state in NetState.Instances)
            {
                Mobile m = state.Mobile;

                if (m != null && m is PlayerMobile && m.AccessLevel <= Config.MaxAccessLevel)
                {
                    if (Config.DropOnBank && m.BankBox != null)
                    {
                        Item kudosrewarddeed = m.BankBox.FindItemByType(typeof(KudosRewardDeed));

                        if (kudosrewarddeed != null)
                        {
                            kudosrewarddeed.Amount++;
                        }
                        else
                        {
                            //m.BankBox.DropItem(new Kudos( Utility.Random( 20, 40 )));
                            m.BankBox.DropItem(new KudosRewardDeed());                           
                        }
                    }
                    else if (m.Backpack != null)
                    {
                        Item kudosrewarddeed = m.Backpack.FindItemByType(typeof(KudosRewardDeed));

                        if (kudosrewarddeed != null)
                        {
                            kudosrewarddeed.Amount++;
                        }
                        else
                        {
                            //m.Backpack.DropItem(new Kudos( Utility.Random( 20, 40 )));
                            m.BankBox.DropItem(new KudosRewardDeed());                           
                        }
                    }
                }
            }
        }
    }

    public class KudosRewardDeed : Item
    {

        [Constructable]
        public KudosRewardDeed() : this( null )
        {
        }

        [Constructable]
        public KudosRewardDeed(string name) : base(5360)
          
        {
            Name = "A Kudos Reward Deed for a random amount of Kudos";
            Hue = 1150;
            Stackable = false;           
        }

        public KudosRewardDeed ( Serial serial ) : base ( serial )
        {
        }

              public override void OnDoubleClick( Mobile from )
              {
            if ( !IsChildOf( from.Backpack ) )
            {
                from.SendLocalizedMessage(1042001);
            }
            else
            {
                            switch ( Utility.Random( 1 ) )
                            {
                               
                                case  0: from.AddToBackpack( new Kudos ( Utility.Random( 18, 25 ))); break;
                           
                            }
                this.Delete();
            }

        }

        public override void Serialize ( GenericWriter writer)
        {
            base.Serialize ( writer );

            writer.Write ( (int) 0);
        }

        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize ( reader );

            int version = reader.ReadInt();
        }
    }
 
Last edited by a moderator:
Yes, I see that now.:) But, how do I set it to where it'll not combine them? I tried taking out that part of the code and it didn't work... hmm:confused:
Post automatically merged:

This is what I tried but still got the same result... they stacked!
kudosrewarddeed.Amount+= 1;
 
Last edited:
Just replace that whole IF/THEN statement to just the else part:

C#:
m.BankBox.DropItem(new KudosRewardDeed());

So in context it will look like this:

C#:
                    if (Config.DropOnBank && m.BankBox != null)
                    {
                       //m.BankBox.DropItem(new Kudos( Utility.Random( 20, 40 )));
                       m.BankBox.DropItem(new KudosRewardDeed());
                    }


Also you will want to do the same thing with the backpack part, even though it might never get run.
 
Though i've got my character set to Owner and the Kudos script is set to Player my bankbox clutters with the Kudos Reward Deeds. Anyone know why?
 
Code:
//   ___|========================|___
//   \  |  Written by Felladrin  |  /   [Kudos - Exchangeable Game Time Reward] - Current version: 1.3 (September 10, 2013)
//    > |       July 2013        | <
//   /__|========================|__\   Description: An item given to players for each period of time they stay online.

using System;
using Server.Mobiles;
using Server.Network;

namespace Server.Custom.GameTimeReward
{
    public class KudosTimer : Timer
    {
        public static class Config
        {
            public static int MinutesOnline = 30;                            // Every X minutes we give kudos to all players online.
            public static bool DropOnBank = true;                           // Should we place the kudos on character's bankbox (true) or backpack (false)?
            public static AccessLevel MaxAccessLevel = AccessLevel.Player;  // Any character with this access and below receives kudos.
        }

        public static void Initialize()
        {
            new KudosTimer().Start();
        }

        public KudosTimer() : base(TimeSpan.Zero, TimeSpan.FromMinutes(Config.MinutesOnline))
        {
            Priority = TimerPriority.OneMinute;
        }

        protected override void OnTick()
        {
            foreach (NetState state in NetState.Instances)
            {
                Mobile m = state.Mobile;

                if (m != null && m is PlayerMobile && m.AccessLevel <= Config.MaxAccessLevel)
                {
                    if (Config.DropOnBank && m.BankBox != null)
                    {
                       /* Item kudosrewarddeed = m.BankBox.FindItemByType(typeof(KudosRewardDeed));

                        if (kudosrewarddeed != null)
                        {                       
                            kudosrewarddeed.Amount++;                                   
                        }
                        else
                        {*/
                            //m.BankBox.DropItem(new Kudos( Utility.Random( 20, 40 )));
                            m.BankBox.DropItem(new KudosRewardDeed());                           
                        //}
                    }
                    else if (m.Backpack != null)
                    {
                        /*Item kudosrewarddeed = m.Backpack.FindItemByType(typeof(KudosRewardDeed));

                        if (kudosrewarddeed != null)
                        {
                            kudosrewarddeed.Amount++;
                        }
                        else
                        {*/
                            //m.Backpack.DropItem(new Kudos( Utility.Random( 20, 40 )));
                            m.BankBox.DropItem(new KudosRewardDeed());
                                                   
                        }
                    }
                }
            }
        }
   // }

    public class KudosRewardDeed : Item
    {

        [Constructable]
        public KudosRewardDeed() : this( null )
        {
        }

        [Constructable]
        public KudosRewardDeed(string name) : base(5360)
          
        {
            Name = "A Kudos Reward Deed for a random amount of Kudos";
            Hue = 1150;
            Stackable = false;           
        }

        public KudosRewardDeed ( Serial serial ) : base ( serial )
        {
        }

              public override void OnDoubleClick( Mobile from )
              {
            if ( !IsChildOf( from.Backpack ) )
            {
                from.SendLocalizedMessage(1042001);
            }
            else
            {
                            switch ( Utility.Random( 1 ) )
                            {
                               
                                case  0: from.AddToBackpack( new Kudos ( Utility.Random( 18, 25 ))); break;
                           
                            }
                this.Delete();
            }

        }

        public override void Serialize ( GenericWriter writer)
        {
            base.Serialize ( writer );

            writer.Write ( (int) 0);
        }

        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize ( reader );

            int version = reader.ReadInt();
        }
    }
    /*
        public class KudosRewardDeedBag : GiftBox  //Bag
        {
        [Constructable]
        public KudosRewardDeedBag() : this (0x232A) //( 3702 )
        {
        Name = "a Kudos Reward Deed Bag";
        Hue = 1153;
        Weight = 1.0;
        }
        [Constructable]
        public KudosRewardDeedBag( int amount )
        {
            DropItem( new KudosRewardDeed() );
           
           
        }

        public KudosRewardDeedBag( Serial serial ) : base( serial )
        {
        }

        public override void Serialize( GenericWriter writer )
        {
            base.Serialize( writer );

            writer.Write( (int) 0 ); // version
        }

        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );

            int version = reader.ReadInt();
        }
    }
    */   
    public class Kudos : Item
    {
        [Constructable]
        public Kudos(int amount)
        {
            Name = "Kudos";
            ItemID = 0xF11;
            Hue = 0x47E;
            Stackable = true;
            Amount = amount;
            Weight = 0;
        }

        [Constructable]
        public Kudos() : this(1) { }

        public override void GetProperties(ObjectPropertyList list)
        {
            base.GetProperties(list);
            list.Add("Exchangeable Game Time Reward");
        }

        public override bool DisplayWeight { get { return false; } }

        public Kudos(Serial serial) : base(serial) { }

        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);
            writer.Write((int)0);
        }

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();
        }
    }
}
 
Last edited by a moderator:
Well the reason is, that you basically commented out all the code besides

m.BankBox.DropItem(new KudosRewardDeed()); from line 64
 
Try this OnTick method to replace yours. I think this reads a bit better.

C#:
        protected override void OnTick()
        {
            foreach (NetState state in NetState.Instances)
            {
                Mobile m = state.Mobile;
                
                if (m == null || m.AccessLevel > Config.MaxAccessLevel) continue;

                if (m.Player)
                {
                    if (Config.DropOnBank && m.BankBox != null)
                    {
                        m.BankBox.DropItem(new KudosRewardDeed());
                    }
                    else if (m.Backpack != null)
                    {
                        m.Backpack.DropItem(new KudosRewardDeed());
                    }
                }
            }
        }

Well the reason is, that you basically commented out all the code besides

m.BankBox.DropItem(new KudosRewardDeed()); from line 64
This is not exactly true. It was still trying to check MaxAccessLevel. It was hard to tell with all the code comments.
 
Back