|
||
|
|||||||
| Script Support Get support for modifying RunUO Scripts, or writing your own! |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Newbie
Join Date: Aug 2008
Location: Québec
Posts: 45
|
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();
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();
}
}
}
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;
}
}
}
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. |
|
|
|
|
|
#3 (permalink) | |
|
Forum Novice
Join Date: Sep 2007
Posts: 367
|
Quote:
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; Code:
public ChristianMenuGump(object obj, Item OldFlippableItem, Item NewFlippedItem) Code:
NewItem = NewFlippedItem; OldItem = OldFlippableItem; 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. |
|
|
|
|
|
|
#5 (permalink) | |
|
Forum Novice
Join Date: Sep 2007
Posts: 367
|
Quote:
Code:
Item item = new NewItem;
item.MoveToWorld(OldItem.Location, OldItem.Map);
OldItem.Delete();
|
|
|
|
|
|
|
#6 (permalink) |
|
Newbie
Join Date: Aug 2008
Location: Québec
Posts: 45
|
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();
}
}
}
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. |
|
|
|
|
|
#7 (permalink) |
|
Forum Novice
Join Date: Sep 2007
Posts: 367
|
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. |
|
|
|
|
|
#10 (permalink) |
|
Newbie
Join Date: Aug 2008
Location: Québec
Posts: 45
|
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();
}
}
}
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;
}
}
}
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. |
|
|
|
|
|
#13 (permalink) |
|
Newbie
Join Date: Aug 2008
Location: Québec
Posts: 45
|
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! |
|
|
|
|
|
#14 (permalink) |
|
Newbie
Join Date: Aug 2008
Location: Québec
Posts: 45
|
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. |
|
|
|
|
|
#15 (permalink) | |
|
Forum Novice
Join Date: Sep 2007
Posts: 367
|
Quote:
Change this... Code:
AddButton(260, 300, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0); Code:
AddButton(260, 300, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 1); Refer to the documentation syntax: void AddButton( int x, int y, int normalID, int pressedID, int buttonID, GumpButtonType type, int param ) |
|
|
|
|
|
|
#16 (permalink) |
|
Newbie
Join Date: Aug 2008
Location: Québec
Posts: 45
|
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;
}
}
}
|
|
|
|
|
|
#17 (permalink) |
|
Forum Novice
Join Date: Sep 2007
Posts: 367
|
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
}
|
|
|
|
|
|
#19 (permalink) |
|
Newbie
Join Date: Aug 2008
Location: Québec
Posts: 45
|
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. |
|
|
|
|
|
#20 (permalink) | |
|
Forum Novice
Join Date: Sep 2007
Posts: 367
|
Quote:
|
|
|
|
|