Resource icon

Gold Ledger 2014-05-10

Author
Danstuff
Downloads
253
Views
2,685
First release
Last update
Rating
0.00 star(s) 0 ratings
No permission to download Join the discussion

More resources from 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​
[accordion=bright|100%]
{slide=BaseCreature.cs |center}
Open BaseCreature.cs and find this, it will be in the OnDeath method.
Code:
if (!givenFactionKill)
     {
       givenFactionKill = true;
       Faction.HandleDeath(this, ds.m_Mobile);
     }
Above it add this
Code:
#region Alpha Gold Ledger Edit 1
GiveGold.GoldTransfer(ds.m_Mobile, c, this);
#endregion
{/slide}
{slide=PlayerVendorGumps.cs|center}
Open PlayerVendorGumps.cs and find this, it will be in the OnResponse method.
Code:
if ( !m_VI.Valid || !m_VI.Item.IsChildOf( m_Vendor.Backpack ) )
   {
     m_Vendor.SayTo( from, 503216 ); // You can't buy that.
     return;
   }
int totalGold = 0;
Below it add this
Code:
#region Alpha Gold Ledger Edit 1
  if (from.Backpack != null)
  {
  Item item = from.Backpack.FindItemByType(typeof(GoldLedger));
  GoldLedger ledger = item as GoldLedger;
  if (ledger != null)
  totalGold += (ledger.Gold + from.Backpack.GetAmount(typeof(Gold)));
  else
  totalGold += from.Backpack.GetAmount(typeof(Gold));
  }
  if (from.BankBox != null)
  totalGold += from.BankBox.GetAmount(typeof(Gold));
#endregion
A few lines below that find this
Code:
int leftPrice = m_VI.Price;
if (from.Backpack != null)
  leftPrice -= from.Backpack.ConsumeUpTo(typeof(Gold), leftPrice);
if (leftPrice > 0)
  Banker.Withdraw(from, leftPrice);

Comment out this part so it looks like this
Code:
.
if (from.Backpack != null)
   //leftPrice -= from.Backpack.ConsumeUpTo(typeof(Gold), leftPrice);
//if (leftPrice > 0)
  //Banker.Withdraw(from, leftPrice);
Now below
Code:
if (from.Backpack != null)
add this and it will look like this.
Code:
if (from.Backpack != null)
#region Alpha Gold Ledger Edit 2
  {
  Item item = from.Backpack.FindItemByType(typeof(GoldLedger));
  GoldLedger ledger = item as GoldLedger;
  leftPrice -= from.Backpack.ConsumeUpTo(typeof(Gold), leftPrice);
  if (leftPrice > 0 && ledger != null)
  {
  int oleftPrice = leftPrice;
  leftPrice -= ledger.Gold;
  int goldWithdrawn = oleftPrice - leftPrice;
  if (goldWithdrawn > 0)
  {
  ledger.Gold -= oleftPrice;
  from.SendMessage(2125, "{0} gold has been withdrawn from your gold ledger.", goldWithdrawn.ToString("#,0"));
  }
  }
  }
  if (leftPrice > 0 && from.BankBox != null)
  from.BankBox.ConsumeUpTo(typeof(Gold), leftPrice);
#endregion
//leftPrice -= from.Backpack.ConsumeUpTo(typeof(Gold), leftPrice);
//if (leftPrice > 0)
  //Banker.Withdraw(from, leftPrice);
{/slide}
{slide=Container.cs|center}
Now in Container.cs add this new method above the UpdateTotal method.
Code:
#region Alpha Gold Ledger Edit 1
  public override bool OnDroppedToMobile(Mobile from, Mobile target)
  {
  Item gitem = target.Backpack.FindItemByType(typeof(GoldLedger));
  Item thisgitem = this.FindItemByType(typeof(GoldLedger));
  if (gitem != null && thisgitem != null)
  {
  if (target == from)
  from.SendMessage("You can only carry one gold ledger!");
  else
  from.SendMessage("That player can only carry one gold ledger!");
  return false;
  }
  return true;
  }
  public override bool OnDroppedInto(Mobile from, Container target, Point3D p)
     {
       if (from == null || target == null)
       {
         return false;
       }
  Item gitem = target.FindItemByType(typeof(GoldLedger));
  Item thisgitem = FindItemByType(typeof(GoldLedger));
  if (target == from.Backpack)
  {
  if (gitem != null && thisgitem != null)
  {
  from.SendMessage("You can only carry one gold ledger!");
  return false;
  }
  }
  else if (target.IsChildOf(from.Backpack))
  {
  if (gitem != null && thisgitem != null)
  {
  from.SendMessage("You can only carry one gold ledger!");
  return false;
  }
  }
  return target.OnDragDropInto(from, this, p);
  }
  public override bool OnDroppedOnto(Mobile from, Item target)
  {
  Item gitem = from.Backpack.FindItemByType(typeof(GoldLedger));
  Item thisgitem = this.FindItemByType(typeof(GoldLedger));
  if (target == from.Backpack)
  {
  if (gitem != null && thisgitem != null)
  {
  from.SendMessage("You can only carry one gold ledger!");
  return false;
  }
  }
  else if (target.IsChildOf(from.Backpack))
  {
  if (gitem != null && thisgitem != null)
  {
  from.SendMessage("You can only carry one gold ledger!");
  return false;
  }
  }
  return target.OnDragDrop(from, this);
  }
  #endregion
{/slide}
{slide=Gold.cs|center}
Now open Gold.cs add this to the gold construtable so that it looks like this.
Code:
[Constructable]
     public Gold( int amount ) : base( 0xEED )
     {
       Stackable = true;
  #region Alpha Gold Ledger Edit 1
  Weight = GoldLedger.GoldWeight;
  #endregion
       Amount = amount;
     }

Also in Gold.cs you want to add a new method before the script Serilize
Code:
#region Alpha Gold Ledger Edit 2
  public override bool OnMoveOver(Mobile from)
  {
  if (from is PlayerMobile && from.Alive)
  {
  PlayerMobile pm = from as PlayerMobile;
  GiveGold.GoldSweep(pm, this);
  }
  return true;
  }
  //Mod to allow players to double click gold and add to ledger
  public override void OnDoubleClick(Mobile m)
  {
  if (this.Movable)
  {
  Item[] items = m.Backpack.FindItemsByType(typeof(GoldLedger));
  foreach (GoldLedger ledger in items)
  {
  if (ledger.Gold + this.Amount <= 2000000)
  {
  ledger.Gold = (ledger.Gold + Amount);
  this.Delete();
  m.SendMessage("You added {0} gold to your gold ledger.", Amount);
  break;
  }
  }
  }
  }
  #endregion
{/slide}
{slide=BaseVendor.cs|center}
Now open BaseVendor.cs and add a new refence to the top
Code:
#region Alpha Gold Ledger Edit 1
using System.Collections.Generic;
#endregion[/code
Find this
[code]cont = buyer.Backpack;
       if (!bought && cont != null)
       {
and add this directly below it
Code:
#region Alpha Gold Ledger #2
  Item item = buyer.Backpack.FindItemByType(typeof(GoldLedger));
  GoldLedger ledger = item as GoldLedger;
  Item[] item2 = buyer.Backpack.FindItemsByType(typeof(Gold));
  int goldint = 0;
  foreach (Item item3 in item2)
  goldint += item3.Amount;
  #endregion #2
Directly below that make it look like this
Code:
if (cont.ConsumeTotal(typeof(Gold), totalCost))
         {
           bought = true;
  #region Alpha Gold Ledger #3
          if( ledger != null )
         {
           if( (goldint + ledger.Gold) >= totalCost )
           {
             ledger.Gold -= (totalCost - goldint);
             bought = true;
             buyer.SendMessage(2125, "{0} gold has been withdrawn from your gold ledger.", (totalCost - goldint).ToString( "#,0" ));
             cont.ConsumeTotal( typeof( Gold ), goldint);
           }
           else if( ledger.Gold >= totalCost )
           {
             ledger.Gold -= totalCost;
             bought = true;
             buyer.SendMessage(2125, "{0} gold has been withdrawn from your gold ledger.", totalCost.ToString( "#,0" ));
           }
         }
#endregion #3
{/slide}
{slide=SBBanker.cs|center}
Finally if you want the bankers to sell gold ledgers open SBBanker.cs and add this to InternalBuyInfo above ContractOfEmployment
Code:
#region Alpha Gold Ledger
  Add( new GenericBuyInfo( "1047016", typeof( GoldLedger ), 9999, 20, 0x1e22, 0x84D ) ); //9999 is the cost in gold for the gold ledger
  #endregion
{/slide}
[/accordion]

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back