While messing around with Daat's99Tokens I've completely stopped using the TokenLedger as the MasterLooterBackpack has one built in. However LadyLuck and VendorStone Don't recognize this as a proper TokenLedger.
So The only problem I have yet to fix to rectify this problem is:
How would I recode this to search the purchaser's backpack for the amount of Tokens and avoid checking for a Ledger as a whole? The work around I used for the Stone doesn't work in this case.
So The only problem I have yet to fix to rectify this problem is:
How would I recode this to search the purchaser's backpack for the amount of Tokens and avoid checking for a Ledger as a whole? The work around I used for the Stone doesn't work in this case.
Code:
Item[] items = m_From.Backpack.FindItemsByType( typeof( Tokens ) ); //TokenLedger
foreach( Tokens tl in items ) //TokenLedger
{
if ( tl.Owner == m_From.Serial )
{
if ( tl.Tokens >= (i_BuyTickets * i_TicketCost) )
{
if (!(tl.Deleted))
{
tl.Tokens = ( tl.Tokens - (i_BuyTickets * i_TicketCost) );
LotteryTicket lottery = new LotteryTicket();
lottery.DrawingNumber = i_Drawing;
lottery.StartTicketNumber = i_Ticket;
lottery.EndTicketNumber = (i_Ticket + i_BuyTickets - 1);
m_From.AddToBackpack( lottery );
i_Ticket = (i_Ticket + i_BuyTickets);
m_From.CloseGump( typeof( LadyLuckSellingGump ) );
m_From.SendMessage("You bought {0} lottery tickets.", i_BuyTickets);
i_Reward = ( i_Reward + ( i_BuyTickets * (i_TicketCost/2) ) );
}
else
{
m_From.PlaySound(1069); //play Hey!! sound
m_From.SendMessage("Hey, don't try to rob the bank!!!");
m_From.SendGump( new LadyLuckSellingGump( m_From ) );
}
return;
}
}
}