Go Back   RunUO - Ultima Online Emulation > RunUO > Script Support

Script Support Get support for modifying RunUO Scripts, or writing your own!

Reply
 
Thread Tools Display Modes
Old 08-23-2008, 10:34 PM   #1 (permalink)
Newbie
 
Pantoute's Avatar
 
Join Date: Aug 2008
Location: Québec
Posts: 45
Default Flip addons [RunUo 1.0]

Hi! I've just subscribed, but it has been a few weeks since I visit this forum. Well... I'm here because I need help on something I tried to do, but I don't seem to find anyway to make it work. I would really appreciate all the help I can have. Thanks in advance

So here is what I did:

I created a new sort of addons called "Addon2", because I needed to add the OnDoubleClick thing to work and I did not want to screw up anything that already existed.

What I have to do:

I want to make the Addon2 items flippable. I found a way by doing this when I DoubleClick on it:

Code:
                      Item item = new SmallBedEastAddon2();      
                      item.MoveToWorld(this.Location, this.Map); 
                      this.Delete();
so far, all is good. But now I want to create a menu on the OnDoubleClick, to be able to do more things with the Addon2's.

What it is supposed to do, is when I doubleclick on one of the addons that I want to be doubleclicked, a gump appears and asks me a question like :"Voulez-vous tourner cet addon?" It means: "Do you want to turn this addon?".

If I click Yes, the addon flips. When I click no, it exits and that's all.

Here's what I did so far:

One of the addon2

Code:
using System;
using System.Collections;
using Server;
using Server.Misc;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;


namespace Server.Items
{
    public class SmallBedSouthAddon2 : BaseAddon2
    {
        AddonComponent2 ac;
        AddonComponent2 ac2;

        [Constructable]
        public SmallBedSouthAddon2()
        {

            AddonComponent2 ac;
            ac = new AddonComponent2(0xa63);
            ac.Movable = true;
            ac.Name = "Petit lit";
            AddComponent2(ac, 0, 0, 0);


            AddonComponent2 ac2;
            ac2 = new AddonComponent2(0xA5C);
            ac2.Movable = true;
            ac2.Name = "Petit lit";
            AddComponent2(ac2, 0, 1, 0);
        }

        public override void OnDoubleClick(Mobile from)
        {
            object o;
            this = o;

            if (!from.InRange(GetWorldLocation(), 2))
            {
                from.SendMessage("vous êtes trop loin pour tourner le lit");
            }
            else
            {
                from.SendGump(new ChristianMenuGump(o));

                /*  if (tournage = true && from.InRange(GetWorldLocation(), 2)) 
                  {
                      from.SendMessage("Vous tournez le lit");       //This is what I need to be done when I click on the first button of the MenuGump
                      Item item = new SmallBedEastAddon2();        //This is what I need to be done when I click on the first button of the MenuGump
                      item.MoveToWorld(this.Location, this.Map);  //This is what I need to be done when I click on the first button of the MenuGump
                      this.Delete();                                           //This is what I need to be done when I click on the first button of the MenuGump
                  }

                  if (tournage = true && !from.InRange(GetWorldLocation(), 2))
                  {
                      from.SendMessage("vous êtes trop loin pour tourner le lit");
                  }*/
            }
        }

        public SmallBedSouthAddon2(Serial serial)
            : base(serial)
        {
        }

        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            writer.Write((int)0); // version
        }

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();
        }
    }
}
Here's the MenuGump

Code:
using System;
using System.Collections;
using Server;
using Server.Misc;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
using Server.Items;

namespace Server.Gumps
{

    	public class ChristianMenuGump : Gump
	{
            object m_Obj;

        private ChristianMenuGump(object obj): base(0, 0)
		{
            m_Obj = obj;

			AddBackground( 265, 205, 320, 290, 5054 );
			Closable = true;
            Disposable = true;
            Dragable = true;
			Resizable = false;
			
			AddPage( 0 );      			
			
			AddImageTiled( 225, 175, 50, 45, 0xCE );   //Top left corner
			AddImageTiled( 267, 175, 315, 44, 0xC9 );  //Top bar
			AddImageTiled( 582, 175, 43, 45, 0xCF );   //Top right corner
			AddImageTiled( 225, 219, 44, 270, 0xCA );  //Left side
			AddImageTiled( 582, 219, 44, 270, 0xCB );  //Right side
			AddImageTiled( 225, 489, 44, 43, 0xCC );   //Lower left corner
			AddImageTiled( 267, 489, 315, 43, 0xE9 );  //Lower Bar
			AddImageTiled( 582, 489, 43, 43, 0xCD );   //Lower right corner

            AddPage(1);


            AddHtml(260, 254, 300, 140, "Voulez-vous tourner cet addon?", false, false);

            AddButton(260, 300, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0);
            AddHtml(300, 300, 300, 50, "Oui", false, false);

            AddButton(360, 300, 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0);
            AddHtml(400, 300, 300, 50, "Non", false, false);  
		}
        public override void OnResponse(NetState state, RelayInfo info)
        {
            if (info.ButtonID == 1 && info.Switches.Length > 0)
            {
                //It is here that I need to "send" a bool or change or I don't know


                //C'est ici que j'ai besoin "d'envoyer" un bool ou changer ou je sais pas
                
            }

                if (info.ButtonID == 2 && info.Switches.Length > 0)
                    return;
        }
	}
}
So, I want a variable to be "sent" to obj (or o) and when it is true, it "flips" with my method (by deleting and all)

I tried a lot of things, I don't even know if it is possible to do, or if it is the right way to do it.

Thanks to all!

Last edited by Pantoute; 08-24-2008 at 12:44 PM.
Pantoute is offline   Reply With Quote
Old 08-24-2008, 11:41 AM   #2 (permalink)
Newbie
 
Pantoute's Avatar
 
Join Date: Aug 2008
Location: Québec
Posts: 45
Default

If it's not clear, please tell me so I'll explain it all better
Pantoute is offline   Reply With Quote
Old 08-24-2008, 08:26 PM   #3 (permalink)
Forum Novice
 
Tassyon T's Avatar
 
Join Date: Sep 2007
Posts: 367
Default

Quote:
Originally Posted by Pantoute View Post
Hi! I've just subscribed, but it has been a few weeks since I visit this forum. Well... I'm here because I need help on something I tried to do, but I don't seem to find anyway to make it work. I would really appreciate all the help I can have. Thanks in advance

So here is what I did:

I created a new sort of addons called "Addon2", because I needed to add the OnDoubleClick thing to work and I did not want to screw up anything that already existed.

What I have to do:

I want to make the Addon2 items flippable. I found a way by doing this when I DoubleClick on it:

Code:
                      Item item = new SmallBedEastAddon2();      
                      item.MoveToWorld(this.Location, this.Map); 
                      this.Delete();
so far, all is good. But now I want to create a menu on the OnDoubleClick, to be able to do more things with the Addon2's.

What it is supposed to do, is when I doubleclick on one of the addons that I want to be doubleclicked, a gump appears and asks me a question like :"Voulez-vous tourner cet addon?" It means: "Do you want to turn this addon?".

If I click Yes, the addon flips. When I click no, it exits and that's all.

Here's what I did so far:

One of the addon2

Code:
using System;
using System.Collections;
using Server;
using Server.Misc;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;


namespace Server.Items
{
    public class SmallBedSouthAddon2 : BaseAddon2
    {
        AddonComponent2 ac;
        AddonComponent2 ac2;

        [Constructable]
        public SmallBedSouthAddon2()
        {

            AddonComponent2 ac;
            ac = new AddonComponent2(0xa63);
            ac.Movable = true;
            ac.Name = "Petit lit";
            AddComponent2(ac, 0, 0, 0);


            AddonComponent2 ac2;
            ac2 = new AddonComponent2(0xA5C);
            ac2.Movable = true;
            ac2.Name = "Petit lit";
            AddComponent2(ac2, 0, 1, 0);
        }

        public override void OnDoubleClick(Mobile from)
        {
            object o;
            this = o;

            if (!from.InRange(GetWorldLocation(), 2))
            {
                from.SendMessage("vous êtes trop loin pour tourner le lit");
            }
            else
            {
                from.SendGump(new ChristianMenuGump(o));

                /*  if (tournage = true && from.InRange(GetWorldLocation(), 2)) 
                  {
                      from.SendMessage("Vous tournez le lit");       //This is what I need to be done when I click on the first button of the MenuGump
                      Item item = new SmallBedEastAddon2();        //This is what I need to be done when I click on the first button of the MenuGump
                      item.MoveToWorld(this.Location, this.Map);  //This is what I need to be done when I click on the first button of the MenuGump
                      this.Delete();                                           //This is what I need to be done when I click on the first button of the MenuGump
                  }

                  if (tournage = true && !from.InRange(GetWorldLocation(), 2))
                  {
                      from.SendMessage("vous êtes trop loin pour tourner le lit");
                  }*/
            }
        }

        public SmallBedSouthAddon2(Serial serial)
            : base(serial)
        {
        }

        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            writer.Write((int)0); // version
        }

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();
        }
    }
}
Here's the MenuGump

Code:
using System;
using System.Collections;
using Server;
using Server.Misc;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
using Server.Items;

namespace Server.Gumps
{

    	public class ChristianMenuGump : Gump
	{
            object m_Obj;

        private ChristianMenuGump(object obj): base(0, 0)
		{
            m_Obj = obj;

			AddBackground( 265, 205, 320, 290, 5054 );
			Closable = true;
            Disposable = true;
            Dragable = true;
			Resizable = false;
			
			AddPage( 0 );      			
			
			AddImageTiled( 225, 175, 50, 45, 0xCE );   //Top left corner
			AddImageTiled( 267, 175, 315, 44, 0xC9 );  //Top bar
			AddImageTiled( 582, 175, 43, 45, 0xCF );   //Top right corner
			AddImageTiled( 225, 219, 44, 270, 0xCA );  //Left side
			AddImageTiled( 582, 219, 44, 270, 0xCB );  //Right side
			AddImageTiled( 225, 489, 44, 43, 0xCC );   //Lower left corner
			AddImageTiled( 267, 489, 315, 43, 0xE9 );  //Lower Bar
			AddImageTiled( 582, 489, 43, 43, 0xCD );   //Lower right corner

            AddPage(1);


            AddHtml(260, 254, 300, 140, "Voulez-vous tourner cet addon?", false, false);

            AddButton(260, 300, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0);
            AddHtml(300, 300, 300, 50, "Oui", false, false);

            AddButton(360, 300, 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0);
            AddHtml(400, 300, 300, 50, "Non", false, false);  
		}
        public override void OnResponse(NetState state, RelayInfo info)
        {
            if (info.ButtonID == 1 && info.Switches.Length > 0)
            {
                //It is here that I need to "send" a bool or change or I don't know


                //C'est ici que j'ai besoin "d'envoyer" un bool ou changer ou je sais pas
                
            }

                if (info.ButtonID == 2 && info.Switches.Length > 0)
                    return;
        }
	}
}
So, I want a variable to be "sent" to obj (or o) and when it is true, it "flips" with my method (by deleting and all)

I tried a lot of things, I don't even know if it is possible to do, or if it is the right way to do it.

Thanks to all!

What I would do, personally, would be to flip the item in the gump. Instead of sending an argument back to the item, just send an argument to the gump, when you call it.

i.e.

1. Declare new private items under the gump class you've made --

Code:
private Item NewItem;
private Item OldItem;
2. Add two other arguments to your gump, (assuming your current argument object obj is the player doing the double clicking i.e.:

Code:
public ChristianMenuGump(object obj, Item OldFlippableItem, Item NewFlippedItem)
3. Define your private int as the passed argument to the gump...

Code:
NewItem = NewFlippedItem;
OldItem = OldFlippableItem;
4. On your OnResponse() method in the gump, run your code. i.e.:

Code:
                   Item item = new NewItem;        
                      item.MoveToWorld(this.Location, this.Map);  
                      OldItem.Delete();

To run the gump, fill in the arguments from your item in the OnDoubleClick() method of the addon.
Tassyon T is offline   Reply With Quote
Old 08-24-2008, 08:31 PM   #4 (permalink)
Newbie
 
Pantoute's Avatar
 
Join Date: Aug 2008
Location: Québec
Posts: 45
Default

Actually, object obj was supposed to be the item double-clicked, but I see what you mean and I will try it and give feedback.
Pantoute is offline   Reply With Quote
Old 08-24-2008, 08:34 PM   #5 (permalink)
Forum Novice
 
Tassyon T's Avatar
 
Join Date: Sep 2007
Posts: 367
Default

Quote:
Originally Posted by Pantoute View Post
Actually, object obj was supposed to be the item double-clicked, but I see what you mean and I will try it and give feedback.
Bah, I missed this when I was copy-pasting over the code snippet you provided:

Code:
                   Item item = new NewItem;        
                      item.MoveToWorld(OldItem.Location, OldItem.Map);  
                      OldItem.Delete();
Tassyon T is offline   Reply With Quote
Old 08-24-2008, 08:42 PM   #6 (permalink)
Newbie
 
Pantoute's Avatar
 
Join Date: Aug 2008
Location: Québec
Posts: 45
Default

I'm not really sure what to do with the addon and give "variables" to things. I'm what you could call a noob in this :P

Code:
using System;
using System.Collections;
using Server;
using Server.Misc;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;


namespace Server.Items
{
    public class SmallBedSouthAddon2 : BaseAddon2
    {
        AddonComponent2 ac;
        AddonComponent2 ac2;

        [Constructable]
        public SmallBedSouthAddon2()
        {

            AddonComponent2 ac;
            ac = new AddonComponent2(0xa63);
            ac.Movable = true;
            ac.Name = "Petit lit";
            AddComponent2(ac, 0, 0, 0);


            AddonComponent2 ac2;
            ac2 = new AddonComponent2(0xA5C);
            ac2.Movable = true;
            ac2.Name = "Petit lit";
            AddComponent2(ac2, 0, 1, 0);
        }

        public override void OnDoubleClick(Mobile from)
        {
            object o;
            from = o;
            item x;
            this = x;
            item y;
            new SmallBedEastAddon2() = y;

            if (!from.InRange(GetWorldLocation(), 2))
            {
                from.SendMessage("vous êtes trop loin pour tourner le lit");
            }
            else
            {
                from.SendGump(new ChristianMenuGump(o, x, y));

                /*  if (tournage = true && from.InRange(GetWorldLocation(), 2)) 
                  {
                      from.SendMessage("Vous tournez le lit");    //That is what I need to be done when I click on the first button of the MenuGump
                      Item item = new SmallBedEastAddon2();       //That is what I need to be done when I click on the first button of the MenuGump
                      item.MoveToWorld(this.Location, this.Map);  //That is what I need to be done when I click on the first button of the MenuGump
                      this.Delete();                              //That is what I need to be done when I click on the first button of the MenuGump
                  }

                  if (tournage = true && !from.InRange(GetWorldLocation(), 2))
                  {
                      from.SendMessage("vous êtes trop loin pour tourner le lit");
                  }*/
            }
        }

        public SmallBedSouthAddon2(Serial serial)
            : base(serial)
        {
        }

        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            writer.Write((int)0); // version
        }

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();
        }
    }
 }
Is that what I have to do? and then the three things o, x, y will be called object obj, Item OldFlippableItem, Item NewFlippedItem in the gump?

But for the rest, all is correct for now. (except that it does'nt compile)

Last edited by Pantoute; 08-24-2008 at 08:45 PM.
Pantoute is offline   Reply With Quote
Old 08-24-2008, 08:45 PM   #7 (permalink)
Forum Novice
 
Tassyon T's Avatar
 
Join Date: Sep 2007
Posts: 367
Default

er, no... you're writing your stuff backwards.


Code:
            // object o;
            //from = o;
            object o;
            o = from;

            //item x;
            //this = x;
            item x;
            x = this;
           
           // item y;
           // new SmallBedEastAddon2() = y;
           item y;
           y = new SmallBedEastAddon2() ;

Last edited by Tassyon T; 08-24-2008 at 08:48 PM.
Tassyon T is offline   Reply With Quote
Old 08-24-2008, 08:45 PM   #8 (permalink)
Newbie
 
Pantoute's Avatar
 
Join Date: Aug 2008
Location: Québec
Posts: 45
Default

well I got a lot of errors

I'll write down them.


Edit after your edit:

I didn't know that it made any difference, I'll try, thanks.

Last edited by Pantoute; 08-24-2008 at 08:48 PM.
Pantoute is offline   Reply With Quote
Old 08-24-2008, 08:48 PM   #9 (permalink)
Forum Novice
 
Tassyon T's Avatar
 
Join Date: Sep 2007
Posts: 367
Default

Quote:
Originally Posted by Pantoute View Post
well I got a lot of errors

I'll write down them.


Edit after your edit:

I didn't know that it made any difference, I'll try, thanks.
paste both scripts, and copy the errors from the compile.
Tassyon T is offline   Reply With Quote
Old 08-24-2008, 08:53 PM   #10 (permalink)
Newbie
 
Pantoute's Avatar
 
Join Date: Aug 2008
Location: Québec
Posts: 45
Default

The addon

Code:
using System;
using System.Collections;
using Server;
using Server.Misc;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;


namespace Server.Items
{
    public class SmallBedSouthAddon2 : BaseAddon2
    {
        AddonComponent2 ac;
        AddonComponent2 ac2;

        [Constructable]
        public SmallBedSouthAddon2()
        {

            AddonComponent2 ac;
            ac = new AddonComponent2(0xa63);
            ac.Movable = true;
            ac.Name = "Petit lit";
            AddComponent2(ac, 0, 0, 0);


            AddonComponent2 ac2;
            ac2 = new AddonComponent2(0xA5C);
            ac2.Movable = true;
            ac2.Name = "Petit lit";
            AddComponent2(ac2, 0, 1, 0);
        }

        public override void OnDoubleClick(Mobile from)
        {
            // object o;
            //from = o;
            object o;
            o = from;

            //item x;
            //this = x;
            item x;
            x = this;

            // item y;
            // new SmallBedEastAddon2() = y;
            item y;
            y = new SmallBedEastAddon2();

            if (!from.InRange(GetWorldLocation(), 2))
            {
                from.SendMessage("vous êtes trop loin pour tourner le lit");
            }
            else
            {
                from.SendGump(new ChristianMenuGump(o, x, y));

                /*  if (tournage = true && from.InRange(GetWorldLocation(), 2)) 
                  {
                      from.SendMessage("Vous tournez le lit");    //That is what I need to be done when I click on the first button of the MenuGump
                      Item item = new SmallBedEastAddon2();       //That is what I need to be done when I click on the first button of the MenuGump
                      item.MoveToWorld(this.Location, this.Map);  //That is what I need to be done when I click on the first button of the MenuGump
                      this.Delete();                              //That is what I need to be done when I click on the first button of the MenuGump
                  }

                  if (tournage = true && !from.InRange(GetWorldLocation(), 2))
                  {
                      from.SendMessage("vous êtes trop loin pour tourner le lit");
                  }*/
            }
        }

        public SmallBedSouthAddon2(Serial serial)
            : base(serial)
        {
        }

        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            writer.Write((int)0); // version
        }

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();
        }
    }
}
The gump

Code:
using System;
using System.Collections;
using Server;
using Server.Misc;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
using Server.Items;

namespace Server.Gumps
{

    	public class ChristianMenuGump : Gump
	{
            object m_Obj;
            private Item NewItem;
            private Item OldItem;

            public ChristianMenuGump(object obj, Item OldFlippableItem, Item NewFlippedItem): base(0, 0)
		{
            m_Obj = obj;
            NewItem = NewFlippedItem;
            OldItem = OldFlippableItem;

			AddBackground( 265, 205, 320, 290, 5054 );
			Closable = true;
            Disposable = true;
            Dragable = true;
			Resizable = false;
			
			AddPage( 0 );      			
			
			AddImageTiled( 225, 175, 50, 45, 0xCE );   //Top left corner
			AddImageTiled( 267, 175, 315, 44, 0xC9 );  //Top bar
			AddImageTiled( 582, 175, 43, 45, 0xCF );   //Top right corner
			AddImageTiled( 225, 219, 44, 270, 0xCA );  //Left side
			AddImageTiled( 582, 219, 44, 270, 0xCB );  //Right side
			AddImageTiled( 225, 489, 44, 43, 0xCC );   //Lower left corner
			AddImageTiled( 267, 489, 315, 43, 0xE9 );  //Lower Bar
			AddImageTiled( 582, 489, 43, 43, 0xCD );   //Lower right corner

            AddPage(1);


            AddHtml(260, 254, 300, 140, "Voulez-vous tourner cet addon?", false, false);

            AddButton(260, 300, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0);
            AddHtml(300, 300, 300, 50, "Oui", false, false);

            AddButton(360, 300, 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0);
            AddHtml(400, 300, 300, 50, "Non", false, false);  
		}
        public override void OnResponse(NetState state, RelayInfo info)
        {
            if (info.ButtonID == 1 && info.Switches.Length > 0)
            {
                      Item item = new NewItem();
                      item.MoveToWorld(OldItem.Location, OldItem.Map);  
                      OldItem.Delete();
                //It is here that I need to "send" a bool or change or I don't know


                //C'est ici que j'ai besoin "d'envoyer" un bool ou changer ou je sais pas
                
            }

                if (info.ButtonID == 2 && info.Switches.Length > 0)
                    return;
        }
	}
}
For now I will put the "oui" answer like that. When it will work I will put it the way I wanted (with the distance and all)

Here are the errors



Aww! I forgot that it was all in french... Do you want me to translate them? And I wanted to make a quick move..

I have 7 errors

in fact, it seems that my addon doesn't recognize the x and y.

Do yoyu want more exactly translated? It could be complicated to have the exact english words

Last edited by Pantoute; 08-24-2008 at 08:56 PM.
Pantoute is offline   Reply With Quote
Old 08-24-2008, 08:57 PM   #11 (permalink)
Forum Novice
 
Tassyon T's Avatar
 
Join Date: Sep 2007
Posts: 367
Default

Sorry... first try this... my bad.

// object o;
//from = o;
object o;
o = from;

//item x;
//this = x;
Item x;
x = this;

// item y;
// new SmallBedEastAddon2() = y;
Item y;
y = new SmallBedEastAddon2();
Tassyon T is offline   Reply With Quote
Old 08-24-2008, 09:02 PM   #12 (permalink)
Forum Novice
 
Tassyon T's Avatar
 
Join Date: Sep 2007
Posts: 367
Default

Also...

Code:
            if (info.ButtonID == 1 && info.Switches.Length > 0)
            {
                Item item = NewItem;
                item.MoveToWorld(OldItem.Location, OldItem.Map);
                OldItem.Delete();
This should fix the gump issue.
Tassyon T is offline   Reply With Quote
Old 08-24-2008, 09:04 PM   #13 (permalink)
Newbie
 
Pantoute's Avatar
 
Join Date: Aug 2008
Location: Québec
Posts: 45
Default

I guess that I didn't paid attention either :P

By the way, I'm from Québec, so sorry for my English

YES! A single error now! I'll try to translate it:

Error gngn ngng ChristianMenuGump.cs blabla (line 57, col. 39) 'server.Gumps.ChristianMenuGump.NewItem designates "field" where "class" was supposed to be (or something like that)

EDIT: It actually compiles! I'll test it and give feedback!
Pantoute is offline   Reply With Quote
Old 08-24-2008, 09:08 PM   #14 (permalink)
Newbie
 
Pantoute's Avatar
 
Join Date: Aug 2008
Location: Québec
Posts: 45
Default

All seems all right, except when I press the "oui" (yes) button.

It simply does nothing. The bed doesn't flip or get deleted

By the way I don't have any errors now. The bed simply doesn't flip

Last edited by Pantoute; 08-24-2008 at 09:12 PM.
Pantoute is offline   Reply With Quote
Old 08-24-2008, 09:21 PM   #15 (permalink)
Forum Novice
 
Tassyon T's Avatar
 
Join Date: Sep 2007
Posts: 367
Default

Quote:
Originally Posted by Pantoute View Post
All seems all right, except when I press the "oui" (yes) button.

It simply does nothing. The bed doesn't flip or get deleted

By the way I don't have any errors now. The bed simply doesn't flip


Change this...

Code:
       AddButton(260, 300, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0);
to this:

Code:
  AddButton(260, 300, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 1);
This number is the return value of a reply-type button

Refer to the documentation syntax:

void AddButton( int x, int y, int normalID, int pressedID, int buttonID, GumpButtonType type, int param )
Tassyon T is offline   Reply With Quote
Old 08-24-2008, 09:28 PM   #16 (permalink)
Newbie
 
Pantoute's Avatar
 
Join Date: Aug 2008
Location: Québec
Posts: 45
Default

For some reason, it still doesn't work. i've put a send message thing, to see if I could see the text, put even that didn't appear. Here are the new versions, still without "errors" from the compiler

Code:
using System;
using System.Collections;
using Server;
using Server.Misc;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;


namespace Server.Items
{
    public class SmallBedSouthAddon2 : BaseAddon2
    {
        AddonComponent2 ac;
        AddonComponent2 ac2;

        [Constructable]
        public SmallBedSouthAddon2()
        {

            AddonComponent2 ac;
            ac = new AddonComponent2(0xa63);
            ac.Movable = true;
            ac.Name = "Petit lit";
            AddComponent2(ac, 0, 0, 0);


            AddonComponent2 ac2;
            ac2 = new AddonComponent2(0xA5C);
            ac2.Movable = true;
            ac2.Name = "Petit lit";
            AddComponent2(ac2, 0, 1, 0);
        }

        public override void OnDoubleClick(Mobile from)
        {
            // object o;
            //from = o;
            Mobile o;
            o = from;

            //item x;
            //this = x;
            Item x;
            x = this;

            // item y;
            // new SmallBedEastAddon2() = y;
            Item y;
            y = new SmallBedEastAddon2();

            if (!from.InRange(GetWorldLocation(), 2))
            {
                from.SendMessage("vous êtes trop loin pour tourner le lit");
            }
            else
            {
                from.SendGump(new ChristianMenuGump(o, x, y));

                /*  if (tournage = true && from.InRange(GetWorldLocation(), 2)) 
                  {
                      from.SendMessage("Vous tournez le lit");    //That is what I need to be done when I click on the first button of the MenuGump
                      Item item = new SmallBedEastAddon2();       //That is what I need to be done when I click on the first button of the MenuGump
                      item.MoveToWorld(this.Location, this.Map);  //That is what I need to be done when I click on the first button of the MenuGump
                      this.Delete();                              //That is what I need to be done when I click on the first button of the MenuGump
                  }

                  if (tournage = true && !from.InRange(GetWorldLocation(), 2))
                  {
                      from.SendMessage("vous êtes trop loin pour tourner le lit");
                  }*/
            }
        }

        public SmallBedSouthAddon2(Serial serial)
            : base(serial)
        {
        }

        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            writer.Write((int)0); // version
        }

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();
        }
    }
}
Code:
using System;
using System.Collections;
using Server;
using Server.Misc;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
using Server.Items;

namespace Server.Gumps
{

    	public class ChristianMenuGump : Gump
	{
            Mobile m_Obj;
            private Item NewItem;
            private Item OldItem;

            public ChristianMenuGump(Mobile obj, Item OldFlippableItem, Item NewFlippedItem): base(0, 0)
		{
            m_Obj = obj;
            NewItem = NewFlippedItem;
            OldItem = OldFlippableItem;

			AddBackground( 265, 205, 320, 290, 5054 );
			Closable = true;
            Disposable = true;
            Dragable = true;
			Resizable = false;
			
			AddPage( 0 );      			
			
			AddImageTiled( 225, 175, 50, 45, 0xCE );   //Top left corner
			AddImageTiled( 267, 175, 315, 44, 0xC9 );  //Top bar
			AddImageTiled( 582, 175, 43, 45, 0xCF );   //Top right corner
			AddImageTiled( 225, 219, 44, 270, 0xCA );  //Left side
			AddImageTiled( 582, 219, 44, 270, 0xCB );  //Right side
			AddImageTiled( 225, 489, 44, 43, 0xCC );   //Lower left corner
			AddImageTiled( 267, 489, 315, 43, 0xE9 );  //Lower Bar
			AddImageTiled( 582, 489, 43, 43, 0xCD );   //Lower right corner

            AddPage(1);


            AddHtml(260, 254, 300, 140, "Voulez-vous tourner cet addon?", false, false);

            AddButton(260, 300, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 1);
            AddHtml(300, 300, 300, 50, "Oui", false, false);

            AddButton(360, 300, 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0);
            AddHtml(400, 300, 300, 50, "Non", false, false);  
		}
        public override void OnResponse(NetState state, RelayInfo info)
        {
            if (info.ButtonID == 1 && info.Switches.Length > 0)
            {
                      m_Obj.SendMessage("Vous tournez le lit");
                      Item item = NewItem;
                      item.MoveToWorld(OldItem.Location, OldItem.Map);  
                      OldItem.Delete();
                //It is here that I need to "send" a bool or change or I don't know


                //C'est ici que j'ai besoin "d'envoyer" un bool ou changer ou je sais pas
                
            }

                if (info.ButtonID == 2 && info.Switches.Length > 0)
                    return;
        }
	}
}
Pantoute is offline   Reply With Quote
Old 08-24-2008, 09:53 PM   #17 (permalink)
Forum Novice
 
Tassyon T's Avatar
 
Join Date: Sep 2007
Posts: 367
Default

Maybe you got your buttons mixed up?

Or...

I'm not sure what this code is supposed to do...

Code:
        public override void OnResponse(NetState state, RelayInfo info)
        {
            if (info.ButtonID == 1 && info.Switches.Length > 0)
            {
                      m_Obj.SendMessage("Vous tournez le lit");
                      Item item = NewItem;
                      item.MoveToWorld(OldItem.Location, OldItem.Map);  
                      OldItem.Delete();
                //It is here that I need to "send" a bool or change or I don't know


                //C'est ici que j'ai besoin "d'envoyer" un bool ou changer ou je sais pas
                
            }

but perhaps you could just drop it:

Code:
        public override void OnResponse(NetState state, RelayInfo info)
        {
            if (info.ButtonID == 1)
            {
                      m_Obj.SendMessage("Vous tournez le lit");
                      Item item = NewItem;
                      item.MoveToWorld(OldItem.Location, OldItem.Map);  
                      OldItem.Delete();
                //It is here that I need to "send" a bool or change or I don't know


                //C'est ici que j'ai besoin "d'envoyer" un bool ou changer ou je sais pas
                
            }
Tassyon T is offline   Reply With Quote
Old 08-24-2008, 09:53 PM   #18 (permalink)
Newbie
 
Pantoute's Avatar
 
Join Date: Aug 2008
Location: Québec
Posts: 45
Default

Do you want me to send you my BaseAddon2 and my AddonComponent2, in case you want to test? Or you won't get it to work I think

Also, there could be something in that, that is important, I don't know...
Pantoute is offline   Reply With Quote
Old 08-24-2008, 09:58 PM   #19 (permalink)
Newbie
 
Pantoute's Avatar
 
Join Date: Aug 2008
Location: Québec
Posts: 45
Default

I removed what you told me and it worked!!!!!!!! I must say that I based my script from ReportMurderer.cs.I didn't realize that it was useless.

Thank you VERY much! I've tried for days to get it to work and I never got it to work. thanks! It is very appreciated! Merci beaucoup!

Last edited by Pantoute; 08-24-2008 at 10:02 PM.
Pantoute is offline   Reply With Quote
Old 08-24-2008, 10:04 PM   #20 (permalink)
Forum Novice
 
Tassyon T's Avatar
 
Join Date: Sep 2007
Posts: 367
Default

Quote:
Originally Posted by Pantoute View Post
I removed what you told me and it worked!!!!!!!! I must say that I based my script from ReportMurderer.cs.I didn't realize that it was useless.

Thank you VERY much! I've tried for days to get it to work and I never got it to work. thanks! It is very appreciated! Merci beaucoup!
ahh der ian!
Tassyon T is offline   Reply With Quote
Old 08-24-2008, 10:07 PM   #21 (permalink)
Newbie