RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Insurance Gump Problem

Friendly_Bob

Sorceror
Code:
using System;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Commands;
using Server.Mobiles;

namespace Server.Gumps
{
    public class InsuranceGump : Gump
    {
        public InsuranceGump() : base( 0, 0 )
        {
            this.Closable=true;
            this.Disposable=true;
            this.Dragable=true;
            this.Resizable=false;

            AddPage(0);
            AddButton(636, 420, 4005, 248, 0,(int)Buttons.Button1, GumpButtonType.Reply, 0);
            AddButton(636, 549, 4005, 248, 0,(int)Buttons.Button2, GumpButtonType.Reply, 0);
            AddButton(19, 553, 4017, 248, 0, (int)Buttons.Button3, GumpButtonType.Reply, 0);
            AddCheck(637, 15, 9725, 9724, false, (int)Buttons.Checkbox1);
            AddCheck(636, 107, 9725, 9724, false, (int)Buttons.Checkbox2);
            AddCheck(636, 180, 9725, 9724, false, (int)Buttons.Checkbox3);
            AddCheck(636, 255, 9725, 9724, false, (int)Buttons.Checkbox4);
            AddCheck(636, 336, 9725, 9724, false, (int)Buttons.Checkbox5);
            AddLabel(54, 556, 0, @"CANCEL");
            AddLabel(671, 550, 0, @"OK");
            AddLabel(670, 417, 0, @"NEXT PAGE");
            AddLabel(23, 526, 0, @"NUMBER OF DEATHS PAYABLE: ");
            AddLabel(23, 503, 0, @"TOTAL COST OF INSURANCE: ");
            AddLabel(23, 483, 0, @"GOLD AVAILABLE: ");
            AddImage(64, 254, 2328);
            AddImage(64, 333, 2328);
            AddImage(64, 180, 2328);
            AddImage(64, 107, 2328);
            AddLabel(68, 88, 0, @"Item");
            AddLabel(364, 88, 0, @"Cost");
            AddLabel(627, 88, 0, @"Insured");
            AddImage(363, 588, 5061);
            AddImage(12, 0, 5061);
            AddImage(0, 272, 5057);
            AddImage(0, 10, 5057);
            AddImage(363, 0, 5061);
            AddImage(11, 588, 5061);
            AddImage(788, 272, 5057);
            AddImage(788, 10, 5057);
            AddImage(-1, 588, 5060);
            AddImage(790, 588, 5062);
            AddImage(0, -2, 5054);
            AddImage(790, -2, 5056);
            AddImage(608, 45, 5101);
            AddImage(698, 45, 5101);
            AddImage(518, 45, 5101);
            AddImage(428, 45, 5101);
            AddImage(338, 45, 5101);
            AddImage(248, 45, 5101);
            AddImage(158, 45, 5101);
            AddImage(68, 45, 5101);
            AddImage(12, 45, 5101);
            AddImage(12, 469, 5101);
            AddImage(102, 469, 5101);
            AddImage(192, 469, 5101);
            AddImage(282, 469, 5101);
            AddImage(372, 469, 5101);
            AddImage(462, 469, 5101);
            AddImage(552, 469, 5101);
            AddImage(642, 469, 5101);
            AddImage(698, 469, 5101);
            AddLabel(14, 15, 0, @"ITEM INSURANCE MENU");
            AddLabel(669, 18, 0, @"AUTO REINSURE");
            

            
        }

        public enum Buttons
        {
            Checkbox1,
            Checkbox2,
            Checkbox3,
            Checkbox4,
            Checkbox5,
            Button1,
            Button2,
            Button3,
        }


        public static int GetBalance(Mobile from)
        {
            Item[] gold, checks;

            return GetBalance(from, out gold, out checks);
        }

        public static int GetBalance(Mobile from, out Item[] gold, out Item[] checks)
        {
            int balance = 0;

            Container bank = from.FindBankNoCreate();

            if (bank != null)
            {
                gold = bank.FindItemsByType(typeof(Gold));
                checks = bank.FindItemsByType(typeof(BankCheck));

                for (int i = 0; i < gold.Length; ++i)
                    balance += gold[i].Amount;

                for (int i = 0; i < checks.Length; ++i)
                    balance += ((BankCheck)checks[i]).Worth;
            }
            else
            {
                gold = checks = new Item[0];
            }

            return balance;
        }

        private static ItemListEntry[] GetEquip(Mobile m)
        {
            ItemListEntry[] entries = new ItemListEntry[m.Items.Count];

            for (int i = 0; i < m.Items.Count; ++i)
            {
                Item item = m.Items[i];

                entries[i] = new ItemListEntry(String.Format("{0}: {1}", item.Layer, item.GetType().Name), item.ItemID, item.Hue);
            }

            return entries;
        }


        public override void OnResponse(NetState sender, RelayInfo info)
        {
            Mobile from = sender.Mobile;

            switch(info.ButtonID)
            {
                case (int)Buttons.Checkbox1:
                {
                    new TargetCallback(ToggleItemInsurance_Callback);//auto insure
                    break;
                }
                case (int)Buttons.Checkbox2:
                    {
                        new TargetCallback(ToggleItemInsurance_Callback);
                    }
                case (int)Buttons.Checkbox3:
                    {
                        new TargetCallback(ToggleItemInsurance_Callback);
                    }
                case (int)Buttons.Checkbox4:
                    {
                        new TargetCallback(ToggleItemInsurance_Callback);
                    }

            }
        }
    }
}

I got it where it insures and display the total amount but i cant get the item to display
 

Friendly_Bob

Sorceror
on osi it displays the items in the box's in the gump like i tired to look at the auction house but i dont understand how it displays the item
 

Talow

Sorceror
You'll want to add mobile as an argument to the gump. Then you can cycle though the items that are on the player, and choose if they should be displayed in the gump. You'd want to do this at the point where you are creating the gump so that the items will be able to be displayed.
 

UO_Talon

Sorceror
If you search my post I created this gump, it just needs to be finished. All I did so far is just the gump
 

Talow

Sorceror
Code:
public InsuranceGump() : base( 0, 0 )
        {
            this.Closable=true;
            this.Disposable=true;
            this.Dragable=true;
            this.Resizable=false;
 
            AddPage(0);
            AddButton(636, 420, 4005, 248, 0,(int)Buttons.Button1, GumpButtonType.Reply, 0);
            AddButton(636, 549, 4005, 248, 0,(int)Buttons.Button2, GumpButtonType.Reply, 0);
            AddButton(19, 553, 4017, 248, 0, (int)Buttons.Button3, GumpButtonType.Reply, 0);
            AddCheck(637, 15, 9725, 9724, false, (int)Buttons.Checkbox1);
            AddCheck(636, 107, 9725, 9724, false, (int)Buttons.Checkbox2);
            AddCheck(636, 180, 9725, 9724, false, (int)Buttons.Checkbox3);
            AddCheck(636, 255, 9725, 9724, false, (int)Buttons.Checkbox4);
            AddCheck(636, 336, 9725, 9724, false, (int)Buttons.Checkbox5);
            AddLabel(54, 556, 0, @"CANCEL");
            AddLabel(671, 550, 0, @"OK");
            AddLabel(670, 417, 0, @"NEXT PAGE");
            AddLabel(23, 526, 0, @"NUMBER OF DEATHS PAYABLE: ");
            AddLabel(23, 503, 0, @"TOTAL COST OF INSURANCE: ");
            AddLabel(23, 483, 0, @"GOLD AVAILABLE: ");
            AddImage(64, 254, 2328);
            AddImage(64, 333, 2328);
            AddImage(64, 180, 2328);
            AddImage(64, 107, 2328);
            AddLabel(68, 88, 0, @"Item");
            AddLabel(364, 88, 0, @"Cost");
            AddLabel(627, 88, 0, @"Insured");
            AddImage(363, 588, 5061);
            AddImage(12, 0, 5061);
            AddImage(0, 272, 5057);
            AddImage(0, 10, 5057);
            AddImage(363, 0, 5061);
            AddImage(11, 588, 5061);
            AddImage(788, 272, 5057);
            AddImage(788, 10, 5057);
            AddImage(-1, 588, 5060);
            AddImage(790, 588, 5062);
            AddImage(0, -2, 5054);
            AddImage(790, -2, 5056);
            AddImage(608, 45, 5101);
            AddImage(698, 45, 5101);
            AddImage(518, 45, 5101);
            AddImage(428, 45, 5101);
            AddImage(338, 45, 5101);
            AddImage(248, 45, 5101);
            AddImage(158, 45, 5101);
            AddImage(68, 45, 5101);
            AddImage(12, 45, 5101);
            AddImage(12, 469, 5101);
            AddImage(102, 469, 5101);
            AddImage(192, 469, 5101);
            AddImage(282, 469, 5101);
            AddImage(372, 469, 5101);
            AddImage(462, 469, 5101);
            AddImage(552, 469, 5101);
            AddImage(642, 469, 5101);
            AddImage(698, 469, 5101);
            AddLabel(14, 15, 0, @"ITEM INSURANCE MENU");
            AddLabel(669, 18, 0, @"AUTO REINSURE");
           
 
           
        }
this is the section I meant as when it's created.
 

Talow

Sorceror
what I'm suggesting for you would be to add Mobile m as an argument of InsuranceGump.

Doing this gives you access to whatever mobile is passed to the InsuranceGump, afterwords you can then get the details from the mobile inside of the InsuranceGump constructor (where you have all that Add parts for the gump).

With that in mind it would let you use the information from the mobile (such as Items equipted, in the backpack, stat, skills, ext) when creating the gump, you can then apply that information to the gump to display what you are looking for.
 

Talow

Sorceror
Now to create the gump you have to pass the mobile to the gump so when they select the insurance from the context menu it will need to pass the mobile when you send the gump. After that is done you can use the items that are on the mobile (m.Items) That will return all the items that are on the mobile as a list of Item (List<Item>).
 

Friendly_Bob

Sorceror
now the question is how do i get them to display in the boxs? like
Code:
If (InsuranceMenu = Page(0))
{
            AddImage(64, 254, 2328,{0}, m.Item.List);//Item Box
            AddImage(64, 333, 2328, {0}, m.Item.List +1);//ItemBox
            AddImage(64, 180, 2328, {0},m.Item.List +2);//Item box
            AddImage(64, 107, 2328,{0},m.Item.List +3);//ItemBox
}
If (InsuranceMenu = Page(1))
{
             AddImage(64, 254, 2328,{0}, m.Item.List +4);//Item Box
            AddImage(64, 333, 2328, {0}, m.Item.List +5);//ItemBox
            AddImage(64, 180, 2328, {0},m.Item.List +6);//Item box
            AddImage(64, 107, 2328,{0},m.Item.List +7);//ItemBox
}
If (InsuranceMenu = Page(2))
{
             AddImage(64, 254, 2328,{0}, m.Item.List+8);//Item Box
            AddImage(64, 333, 2328, {0}, m.Item.List +9);//ItemBox
            AddImage(64, 180, 2328, {0},m.Item.List +10);//Item box
            AddImage(64, 107, 2328,{0},m.Item.List +11);//ItemBox
}
 

Iraq-

Sorceror
Code:
int itemnum = 0;
 
int yoffset = 20;
 
List<Item> list = new List<Item>();
 
// fill the list
 
// list.Add( from.Backpack ); // example item i'm assuming you have the list already
 
foreach( Item item in list )
 
{
 
if( item != null )
 
{
 
AddItem( 64, 100 + ( itemnum * yoffset ), item.ItemID );
 
itemnum++;
 
}
 
}
 

Iraq-

Sorceror
Code:
AddItem( 64, 100 + ( itemnum * yoffset ), item.ItemID, item.Hue );
use that rather, it'll retain item hue.
 
Top