1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Gold Ledger 2014-05-10

gold sweeper , gold autoloot from mob and check maker

  1. Danstuff
    Merged by Danstuff
    Script Name: Alpha Gold Ledger
    Author: Joeku AKA Demortris
    Mods By:Callandor2k & Prplbeast
    I provided the distro files that have the edits in them, in the archive so that you can see the changes in the entire script(s).
    Place Goldledger.cs and LedgerGoldCommand.cs in your scripts/custom folder.
    Tutorial for Servuo distro file edits​
    BaseCreature.cs

    Open BaseCreature.cs and find this, it will be in the OnDeath method.
    Code (C#):
    1. if (!givenFactionKill)
    2.      {
    3.        givenFactionKill = true;
    4.        Faction.HandleDeath(this, ds.m_Mobile);
    5.      }
    Above it add this
    Code (C#):
    1. #region Alpha Gold Ledger Edit 1
    2. GiveGold.GoldTransfer(ds.m_Mobile, c, this);
    3. #endregion
    PlayerVendorGumps.cs

    Open PlayerVendorGumps.cs and find this, it will be in the OnResponse method.
    Code (C#):
    1. if ( !m_VI.Valid || !m_VI.Item.IsChildOf( m_Vendor.Backpack ) )
    2.    {
    3.      m_Vendor.SayTo( from, 503216 ); // You can't buy that.
    4.      return;
    5.    }
    6. int totalGold = 0;
    Below it add this
    Code (C#):
    1. #region Alpha Gold Ledger Edit 1
    2.   if (from.Backpack != null)
    3.   {
    4.   Item item = from.Backpack.FindItemByType(typeof(GoldLedger));
    5.   GoldLedger ledger = item as GoldLedger;
    6.   if (ledger != null)
    7.   totalGold += (ledger.Gold + from.Backpack.GetAmount(typeof(Gold)));
    8.   else
    9.   totalGold += from.Backpack.GetAmount(typeof(Gold));
    10.   }
    11.   if (from.BankBox != null)
    12.   totalGold += from.BankBox.GetAmount(typeof(Gold));
    13. #endregion
    A few lines below that find this
    Code (C#):
    1. int leftPrice = m_VI.Price;
    2. if (from.Backpack != null)
    3.   leftPrice -= from.Backpack.ConsumeUpTo(typeof(Gold), leftPrice);
    4. if (leftPrice > 0)
    5.   Banker.Withdraw(from, leftPrice);
    Comment out this part so it looks like this
    Code (C#):
    1. .
    2. if (from.Backpack != null)
    3.    //leftPrice -= from.Backpack.ConsumeUpTo(typeof(Gold), leftPrice);
    4. //if (leftPrice > 0)
    5.   //Banker.Withdraw(from, leftPrice);
    Now below
    Code (C#):
    1. if (from.Backpack != null)
    add this and it will look like this.
    Code (C#):
    1. if (from.Backpack != null)
    2. #region Alpha Gold Ledger Edit 2
    3.   {
    4.   Item item = from.Backpack.FindItemByType(typeof(GoldLedger));
    5.   GoldLedger ledger = item as GoldLedger;
    6.   leftPrice -= from.Backpack.ConsumeUpTo(typeof(Gold), leftPrice);
    7.   if (leftPrice > 0 && ledger != null)
    8.   {
    9.   int oleftPrice = leftPrice;
    10.   leftPrice -= ledger.Gold;
    11.   int goldWithdrawn = oleftPrice - leftPrice;
    12.   if (goldWithdrawn > 0)
    13.   {
    14.   ledger.Gold -= oleftPrice;
    15.   from.SendMessage(2125, "{0} gold has been withdrawn from your gold ledger.", goldWithdrawn.ToString("#,0"));
    16.   }
    17.   }
    18.   }
    19.   if (leftPrice > 0 && from.BankBox != null)
    20.   from.BankBox.ConsumeUpTo(typeof(Gold), leftPrice);
    21. #endregion
    22. //leftPrice -= from.Backpack.ConsumeUpTo(typeof(Gold), leftPrice);
    23. //if (leftPrice > 0)
    24.   //Banker.Withdraw(from, leftPrice);
    Container.cs

    Now in Container.cs add this new method above the UpdateTotal method.
    Code (C#):
    1. #region Alpha Gold Ledger Edit 1
    2.   public override bool OnDroppedToMobile(Mobile from, Mobile target)
    3.   {
    4.   Item gitem = target.Backpack.FindItemByType(typeof(GoldLedger));
    5.   Item thisgitem = this.FindItemByType(typeof(GoldLedger));
    6.   if (gitem != null && thisgitem != null)
    7.   {
    8.   if (target == from)
    9.   from.SendMessage("You can only carry one gold ledger!");
    10.   else
    11.   from.SendMessage("That player can only carry one gold ledger!");
    12.   return false;
    13.   }
    14.   return true;
    15.   }
    16.   public override bool OnDroppedInto(Mobile from, Container target, Point3D p)
    17.      {
    18.        if (from == null || target == null)
    19.        {
    20.          return false;
    21.        }
    22.   Item gitem = target.FindItemByType(typeof(GoldLedger));
    23.   Item thisgitem = FindItemByType(typeof(GoldLedger));
    24.   if (target == from.Backpack)
    25.   {
    26.   if (gitem != null && thisgitem != null)
    27.   {
    28.   from.SendMessage("You can only carry one gold ledger!");
    29.   return false;
    30.   }
    31.   }
    32.   else if (target.IsChildOf(from.Backpack))
    33.   {
    34.   if (gitem != null && thisgitem != null)
    35.   {
    36.   from.SendMessage("You can only carry one gold ledger!");
    37.   return false;
    38.   }
    39.   }
    40.   return target.OnDragDropInto(from, this, p);
    41.   }
    42.   public override bool OnDroppedOnto(Mobile from, Item target)
    43.   {
    44.   Item gitem = from.Backpack.FindItemByType(typeof(GoldLedger));
    45.   Item thisgitem = this.FindItemByType(typeof(GoldLedger));
    46.   if (target == from.Backpack)
    47.   {
    48.   if (gitem != null && thisgitem != null)
    49.   {
    50.   from.SendMessage("You can only carry one gold ledger!");
    51.   return false;
    52.   }
    53.   }
    54.   else if (target.IsChildOf(from.Backpack))
    55.   {
    56.   if (gitem != null && thisgitem != null)
    57.   {
    58.   from.SendMessage("You can only carry one gold ledger!");
    59.   return false;
    60.   }
    61.   }
    62.   return target.OnDragDrop(from, this);
    63.   }
    64.   #endregion
    Gold.cs

    Now open Gold.cs add this to the gold construtable so that it looks like this.
    Code (C#):
    1. [Constructable]
    2.      public Gold( int amount ) : base( 0xEED )
    3.      {
    4.        Stackable = true;
    5.   #region Alpha Gold Ledger Edit 1
    6.   Weight = GoldLedger.GoldWeight;
    7.   #endregion
    8.        Amount = amount;
    9.      }
    Also in Gold.cs you want to add a new method before the script Serilize
    Code (C#):
    1. #region Alpha Gold Ledger Edit 2
    2.   public override bool OnMoveOver(Mobile from)
    3.   {
    4.   if (from is PlayerMobile && from.Alive)
    5.   {
    6.   PlayerMobile pm = from as PlayerMobile;
    7.   GiveGold.GoldSweep(pm, this);
    8.   }
    9.   return true;
    10.   }
    11.   //Mod to allow players to double click gold and add to ledger
    12.   public override void OnDoubleClick(Mobile m)
    13.   {
    14.   if (this.Movable)
    15.   {
    16.   Item[] items = m.Backpack.FindItemsByType(typeof(GoldLedger));
    17.   foreach (GoldLedger ledger in items)
    18.   {
    19.   if (ledger.Gold + this.Amount <= 2000000)
    20.   {
    21.   ledger.Gold = (ledger.Gold + Amount);
    22.   this.Delete();
    23.   m.SendMessage("You added {0} gold to your gold ledger.", Amount);
    24.   break;
    25.   }
    26.   }
    27.   }
    28.   }
    29.   #endregion
    BaseVendor.cs

    Now open BaseVendor.cs and add a new refence to the top
    Code (C#):
    1. #region Alpha Gold Ledger Edit 1
    2. using System.Collections.Generic;
    3. #endregion[/code
    4. Find this
    5. [code]cont = buyer.Backpack;
    6.        if (!bought && cont != null)
    7.        {
    and add this directly below it
    Code (C#):
    1. #region Alpha Gold Ledger #2
    2.   Item item = buyer.Backpack.FindItemByType(typeof(GoldLedger));
    3.   GoldLedger ledger = item as GoldLedger;
    4.   Item[] item2 = buyer.Backpack.FindItemsByType(typeof(Gold));
    5.   int goldint = 0;
    6.   foreach (Item item3 in item2)
    7.   goldint += item3.Amount;
    8.   #endregion #2
    Directly below that make it look like this
    Code (C#):
    1. if (cont.ConsumeTotal(typeof(Gold), totalCost))
    2.          {
    3.            bought = true;
    4.   #region Alpha Gold Ledger #3
    5.           if( ledger != null )
    6.          {
    7.            if( (goldint + ledger.Gold) >= totalCost )
    8.            {
    9.              ledger.Gold -= (totalCost - goldint);
    10.              bought = true;
    11.              buyer.SendMessage(2125, "{0} gold has been withdrawn from your gold ledger.", (totalCost - goldint).ToString( "#,0" ));
    12.              cont.ConsumeTotal( typeof( Gold ), goldint);
    13.            }
    14.            else if( ledger.Gold >= totalCost )
    15.            {
    16.              ledger.Gold -= totalCost;
    17.              bought = true;
    18.              buyer.SendMessage(2125, "{0} gold has been withdrawn from your gold ledger.", totalCost.ToString( "#,0" ));
    19.            }
    20.          }
    21. #endregion #3
    SBBanker.cs

    Finally if you want the bankers to sell gold ledgers open SBBanker.cs and add this to InternalBuyInfo above ContractOfEmployment
    Code (C#):
    1. #region Alpha Gold Ledger
    2.   Add( new GenericBuyInfo( "1047016", typeof( GoldLedger ), 9999, 20, 0x1e22, 0x84D ) ); //9999 is the cost in gold for the gold ledger
    3.   #endregion