How to make NPC sell item randomly

Opywang

Squire
Jan 16, 2017
135
2
18
41
Alright on our shard we're going to make some cool feature for clean up braitaina by selling item that come in random by using point, and we don't want players to choose the item, and we think it'll be too powerful if players can choose what they want.

Here is code for selling, and how can we fix the code where it can sell in random, and if it doesn't work then please tell us how to find an another way to make it work.

CleanUpBritanniaRewards.cs

Rewards.Add(new CollectionItem(typeof(KnightsBascinet), 0x140C, 1151247, 1150, 10000));
 

sahisahi

Knight
Jan 13, 2016
835
81
28
You can always add a deed with a random reward from a list and call it Mysterious Reward deed :p

Code:
public override void OnDoubleClick( Mobile from )
              {
            if ( !IsChildOf( from.Backpack ) )
            {
                from.SendLocalizedMessage(1042001);
            }
            else
            {
                switch (Utility.Random(3))
                {
                    case 0: from.AddToBackpack(new Reward); break;
                    case 1: from.AddToBackpack(new BankCheck(1000)); break;
                    case 2: from.AddToBackpack(new IronIngot(100)); break;

                }
                this.Delete();
                from.FixedParticles(0x373A, 10, 15, 5016, EffectLayer.Waist);
                from.PlaySound( 488 );
            }

        }