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!

New Player Ticket OnDoubleClick

Macil

Sorceror
I'm trying to get the New Player Ticket to work simply with an OnDoubleClick rather than having to target someone else's new player ticket. I'd like to remove targeting another ticket completely - I never understood that whole function and it severely over complicated the ticket system in my opinion.

Code:
using System;
using Server.Network;
using Server.Prompts;
using Server.Items;
using Server.Targeting;
using Server.Gumps;
 
namespace Server.Items
{
public class NewPlayerTicket : Item
{
private Mobile m_Owner;
 
[CommandProperty( AccessLevel.GameMaster )]
public Mobile Owner
{
get{ return m_Owner; }
set{ m_Owner = value; }
}
 
public override int LabelNumber{ get{ return 1062094; } } // a young player ticket
 
[Constructable]
public NewPlayerTicket() : base( 0x14EF )
{
Weight = 1.0;
LootType = LootType.Blessed;
}
 
        public override void GetProperties(ObjectPropertyList list)
        {
            base.GetProperties(list);
 
            list.Add( String.Format("Use this to get your young player item"));  // Use this to redeem<br>Your Heritage Items
        }
 
public override bool DisplayLootType{ get{ return false; } }
 
public NewPlayerTicket( Serial serial ) : base( serial )
{
}
 
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
 
writer.Write( (int) 0 ); // version
 
writer.Write( (Mobile) m_Owner );
}
 
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
 
int version = reader.ReadInt();
 
switch ( version )
{
case 0:
{
m_Owner = reader.ReadMobile();
break;
}
}
 
if ( Name == "a young player ticket" )
Name = null;
}
 
        public override void OnDoubleClick(Mobile from, NewPlayerTicket ticket)
        {
            if (IsChildOf(from.Backpack))
            {
                from.CloseGump(typeof(InternalGump));
                from.SendGump( new InternalGump( from));
            }
            else
                from.SendLocalizedMessage(1062334); // This item must be in your backpack to be used.
        }
/*private class InternalTarget : Target
{
private NewPlayerTicket m_Ticket;
 
public InternalTarget( NewPlayerTicket ticket ) : base( 2, false, TargetFlags.None )
{
m_Ticket = ticket;
}
 
protected override void OnTarget( Mobile from, object targeted )
{
if ( targeted == m_Ticket )
{
from.SendLocalizedMessage( 501928 ); // You can't target the same ticket!
}
else if ( targeted is NewPlayerTicket )
{
NewPlayerTicket theirTicket = targeted as NewPlayerTicket;
Mobile them = theirTicket.m_Owner;
 
if ( them == null || them.Deleted )
{
from.SendLocalizedMessage( 501930 ); // That is not a valid ticket.
}
else
{
from.SendGump( new InternalGump( from, m_Ticket ) );
them.SendGump( new InternalGump( them, theirTicket ) );
}
}
else if ( targeted is Item && ((Item)targeted).ItemID == 0x14F0 )
{
from.SendLocalizedMessage( 501931 ); // You need to find another ticket marked NEW PLAYER.
}
else
{
from.SendLocalizedMessage( 501929 ); // You will need to select a ticket.
}
}
} */
 
private class InternalGump : Gump
{
private Mobile m_From;
private NewPlayerTicket m_Ticket;
 
public InternalGump( Mobile from, NewPlayerTicket ticket ) : base( 50, 50 )
{
m_From = from;
m_Ticket = ticket;
 
AddBackground( 0, 0, 400, 385, 0xA28 );
 
AddHtmlLocalized( 30, 45, 340, 70, 1013011, true, true ); // Choose the gift you prefer. WARNING: if you cancel, and your partner does not, you will need to find another matching ticket!
 
AddButton( 46, 128, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 80, 130, 320, 35, 1013012, false, false ); // A sextant
 
AddButton( 46, 163, 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 80, 165, 320, 35, 1013013, false, false ); // A coupon for a single hair restyling
 
AddButton( 46, 198, 0xFA5, 0xFA7, 3, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 80, 200, 320, 35, 1013014, false, false ); // A spellbook with all 1st - 4th spells.
 
AddButton( 46, 233, 0xFA5, 0xFA7, 4, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 80, 235, 320, 35, 1013015, false, false ); // A wand of fireworks
 
AddButton( 46, 268, 0xFA5, 0xFA7, 5, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 80, 270, 320, 35, 1013016, false, false ); // A spyglass
 
AddButton( 46, 303, 0xFA5, 0xFA7, 6, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 80, 305, 320, 35, 1013017, false, false ); // Dyes and a dye tub
 
AddButton( 120, 340, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 154, 342, 100, 35, 1011012, false, false ); // CANCEL
}
 
public override void OnResponse( NetState sender, RelayInfo info )
{
if ( m_Ticket.Deleted )
return;
 
int number = 0;
 
Item item = null;
Item item2 = null;
 
switch ( info.ButtonID )
{
case 1: item = new Sextant(); number = 1010494; break; // A sextant has been placed in your backpack.
case 2: item = new HairRestylingDeed(); number = 501933; break; // A coupon for a free hair restyling has been placed in your backpack.
case 3: item = new Spellbook( 0xFFFFFFFF ); number = 1010495; break; // A spellbook with all 1st to 4th circle spells has been placed in your backpack.
case 4: item = new FireworksWand(); number = 501935; break; // A wand of fireworks has been placed in your backpack.
case 5: item = new Spyglass(); number = 501936; break; // A spyglass has been placed in your backpack.
case 6: item = new DyeTub(); item2 = new Dyes(); number = 501937; break; // The dyes and dye tub have been placed in your backpack.
}
 
if ( item != null )
{
m_Ticket.Delete();
 
m_From.SendLocalizedMessage( number );
m_From.AddToBackpack( item );
 
if ( item2 != null )
m_From.AddToBackpack( item2 );
}
}
}
}
}

Here is what I have so far, and the error I'm getting:

Code:
Errors:
 + Items/Deeds/NewPlayerTicket.cs:
    CS0115: Line 71: 'Server.Items.NewPlayerTicket.OnDoubleClick(Server.Mobile,
Server.Items.NewPlayerTicket)': no suitable method found to override
Scripts: One or more scripts failed to compile or no script files were found.
 - Press return to exit, or R to try again.
 

pooka01

Sorceror
i don't think you need "ticket" in that:
public override void OnDoubleClick(Mobile from, NewPlayerTicket ticket)

EA games being passive aggressive; telling young players to move their asses and talk with other newbies...
lol
 

Macil

Sorceror
I tried without it and still didn't get anywhere. :-/

Is it expecting more after "(Mobile from)???"

Code:
using System;
using Server.Network;
using Server.Prompts;
using Server.Items;
using Server.Targeting;
using Server.Gumps;
 
namespace Server.Items
{
public class NewPlayerTicket : Item
{
private Mobile m_Owner;
 
[CommandProperty( AccessLevel.GameMaster )]
public Mobile Owner
{
get{ return m_Owner; }
set{ m_Owner = value; }
}
 
public override int LabelNumber{ get{ return 1062094; } } // a young player ticket
 
[Constructable]
public NewPlayerTicket() : base( 0x14EF )
{
Weight = 1.0;
LootType = LootType.Blessed;
}
 
        public override void GetProperties(ObjectPropertyList list)
        {
            base.GetProperties(list);
 
            list.Add( String.Format("Use this to get your young player item"));  // Use this to redeem<br>Your Heritage Items
        }
 
public override bool DisplayLootType{ get{ return false; } }
 
public NewPlayerTicket( Serial serial ) : base( serial )
{
}
 
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
 
writer.Write( (int) 0 ); // version
 
writer.Write( (Mobile) m_Owner );
}
 
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
 
int version = reader.ReadInt();
 
switch ( version )
{
case 0:
{
m_Owner = reader.ReadMobile();
break;
}
}
 
if ( Name == "a young player ticket" )
Name = null;
}
 
public override void OnDoubleClick(Mobile from)
        {
            if (IsChildOf(from.Backpack))
            {
                from.SendGump(new InternalGump(from));
                from.SendGump( new InternalGump( from));
            }
            else
                from.SendLocalizedMessage(1062334); // This item must be in your backpack to be used.
        }
/*private class InternalTarget : Target
{
private NewPlayerTicket m_Ticket;
 
public InternalTarget( NewPlayerTicket ticket ) : base( 2, false, TargetFlags.None )
{
m_Ticket = ticket;
}
 
protected override void OnTarget( Mobile from, object targeted )
{
if ( targeted == m_Ticket )
{
from.SendLocalizedMessage( 501928 ); // You can't target the same ticket!
}
else if ( targeted is NewPlayerTicket )
{
NewPlayerTicket theirTicket = targeted as NewPlayerTicket;
Mobile them = theirTicket.m_Owner;
 
if ( them == null || them.Deleted )
{
from.SendLocalizedMessage( 501930 ); // That is not a valid ticket.
}
else
{
from.SendGump( new InternalGump( from, m_Ticket ) );
them.SendGump( new InternalGump( them, theirTicket ) );
}
}
else if ( targeted is Item && ((Item)targeted).ItemID == 0x14F0 )
{
from.SendLocalizedMessage( 501931 ); // You need to find another ticket marked NEW PLAYER.
}
else
{
from.SendLocalizedMessage( 501929 ); // You will need to select a ticket.
}
}
} */
 
private class InternalGump : Gump
{
private Mobile m_From;
private NewPlayerTicket m_Ticket;
 
public InternalGump( Mobile from, NewPlayerTicket ticket ) : base( 50, 50 )
{
m_From = from;
m_Ticket = ticket;
 
AddBackground( 0, 0, 400, 385, 0xA28 );
 
AddHtmlLocalized( 30, 45, 340, 70, 1013011, true, true ); // Choose the gift you prefer. WARNING: if you cancel, and your partner does not, you will need to find another matching ticket!
 
AddButton( 46, 128, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 80, 130, 320, 35, 1013012, false, false ); // A sextant
 
AddButton( 46, 163, 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 80, 165, 320, 35, 1013013, false, false ); // A coupon for a single hair restyling
 
AddButton( 46, 198, 0xFA5, 0xFA7, 3, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 80, 200, 320, 35, 1013014, false, false ); // A spellbook with all 1st - 4th spells.
 
AddButton( 46, 233, 0xFA5, 0xFA7, 4, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 80, 235, 320, 35, 1013015, false, false ); // A wand of fireworks
 
AddButton( 46, 268, 0xFA5, 0xFA7, 5, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 80, 270, 320, 35, 1013016, false, false ); // A spyglass
 
AddButton( 46, 303, 0xFA5, 0xFA7, 6, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 80, 305, 320, 35, 1013017, false, false ); // Dyes and a dye tub
 
AddButton( 120, 340, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 154, 342, 100, 35, 1011012, false, false ); // CANCEL
}
 
public override void OnResponse( NetState sender, RelayInfo info )
{
if ( m_Ticket.Deleted )
return;
 
int number = 0;
 
Item item = null;
Item item2 = null;
 
switch ( info.ButtonID )
{
case 1: item = new Sextant(); number = 1010494; break; // A sextant has been placed in your backpack.
case 2: item = new HairRestylingDeed(); number = 501933; break; // A coupon for a free hair restyling has been placed in your backpack.
case 3: item = new Spellbook( 0xFFFFFFFF ); number = 1010495; break; // A spellbook with all 1st to 4th circle spells has been placed in your backpack.
case 4: item = new FireworksWand(); number = 501935; break; // A wand of fireworks has been placed in your backpack.
case 5: item = new Spyglass(); number = 501936; break; // A spyglass has been placed in your backpack.
case 6: item = new DyeTub(); item2 = new Dyes(); number = 501937; break; // The dyes and dye tub have been placed in your backpack.
}
 
if ( item != null )
{
m_Ticket.Delete();
 
m_From.SendLocalizedMessage( number );
m_From.AddToBackpack( item );
 
if ( item2 != null )
m_From.AddToBackpack( item2 );
}
}
}
}
}

Code:
Errors:
+ Items/Deeds/NewPlayerTicket.cs:
    CS1729: Line 75: 'Server.Items.NewPlayerTicket.InternalGump' does not contai
n a constructor that takes 1 arguments
    CS1729: Line 76: 'Server.Items.NewPlayerTicket.InternalGump' does not contai
n a constructor that takes 1 arguments
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.
 

pooka01

Sorceror
from.SendGump(new InternalGump(from));
from.SendGump( new InternalGump( from));

duplicated lines,
change for only one and make it:
from.SendGump(new InternalGump(from, this));
 

Macil

Sorceror
Hey, that works great! Thank you Pooka. Noticed a slight bug though. Is there any way to block an attempt to open it more than once? It doesn't actually let you pick more than one reward, but my OCD gets the best of me when it comes to stuff like this. Any way to block opening it more than once if it's already open?
 

Macil

Sorceror
Had to add "from, this" to that. But it worked. Thanks again. =)

I'm considering adding this to the script releases for everyone to use. Once again, I feel this is how the new player tickets should have functioned to begin with. Do you want credit for helping me, Pooka?
 

Macil

Sorceror
Okay, almost done here now. The last issue I'm having is trying to write out a custom string (I think I'm saying that right) instead of using the cliloc numbers for each ticket reward option so I can add custom rewards instead of the useless items OSI always stuck us with.

So I added where I think I need to make the changes, I just can't seem to figure out how to change it from a number to a string because typing for instance "100 Bandages" doesn't seem to want to work. :-/

Errors:
+ Items/Deeds/NewPlayerTicket.cs:
CS1502: Line 100: The best overloaded method match for 'Server.Gumps.Gump.Ad
dHtmlLocalized(int, int, int, int, int, bool, bool)' has some invalid arguments
CS1503: Line 100: Argument 5: cannot convert from 'string' to 'int'
CS0201: Line 133: Only assignment, call, increment, decrement, await, and ne
w object expressions can be used as a statement
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.

Code:
using System;
using Server.Network;
using Server.Prompts;
using Server.Items;
using Server.Targeting;
using Server.Gumps;
 
namespace Server.Items
{
    public class NewPlayerTicket : Item
    {
        private Mobile m_Owner;
 
        [CommandProperty(AccessLevel.GameMaster)]
        public Mobile Owner
        {
            get { return m_Owner; }
            set { m_Owner = value; }
        }
 
        public override int LabelNumber { get { return 1062094; } } // a young player ticket
 
        [Constructable]
        public NewPlayerTicket()
            : base(0x14EF)
        {
            Weight = 1.0;
            LootType = LootType.Blessed;
        }
 
        public override void GetProperties(ObjectPropertyList list)
        {
            base.GetProperties(list);
 
            list.Add(String.Format("Use this to get your young player item"));  // Use this to redeem<br>Your Heritage Items
        }
 
        public override bool DisplayLootType { get { return false; } }
 
        public NewPlayerTicket(Serial serial)
            : base(serial)
        {
        }
 
        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);
 
            writer.Write((int)0); // version
 
            writer.Write((Mobile)m_Owner);
        }
 
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
 
            int version = reader.ReadInt();
 
            switch (version)
            {
                case 0:
                    {
                        m_Owner = reader.ReadMobile();
                        break;
                    }
            }
 
            if (Name == "a young player ticket")
                Name = null;
        }
 
        public override void OnDoubleClick(Mobile from)
        {
            if (IsChildOf(from.Backpack))
            {
                from.CloseGump( typeof(InternalGump));
from.SendGump( new InternalGump(from, this));
            }
            else
                from.SendLocalizedMessage(1062334); // This item must be in your backpack to be used.
        }
 
        private class InternalGump : Gump
        {
            private Mobile m_From;
            private NewPlayerTicket m_Ticket;
 
            public InternalGump(Mobile from, NewPlayerTicket ticket)
                : base(50, 50)
            {
                m_From = from;
                m_Ticket = ticket;
 
                AddBackground(0, 0, 400, 385, 0xA28);
 
                AddHtmlLocalized(30, 45, 340, 70, 1013011, true, true); // Choose the gift you prefer. WARNING: if you cancel, and your partner does not, you will need to find another matching ticket!
 
                AddButton(46, 128, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0);
                AddHtmlLocalized(80, 130, 320, 35, "100 bandages", false, false); // A sextant
 
                AddButton(46, 163, 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0);
                AddHtmlLocalized(80, 165, 320, 35, 1013013, false, false); // A coupon for a single hair restyling
 
                AddButton(46, 198, 0xFA5, 0xFA7, 3, GumpButtonType.Reply, 0);
                AddHtmlLocalized(80, 200, 320, 35, 1013014, false, false); // A spellbook with all 1st - 4th spells.
 
                AddButton(46, 233, 0xFA5, 0xFA7, 4, GumpButtonType.Reply, 0);
                AddHtmlLocalized(80, 235, 320, 35, 1013015, false, false); // A wand of fireworks
 
                AddButton(46, 268, 0xFA5, 0xFA7, 5, GumpButtonType.Reply, 0);
                AddHtmlLocalized(80, 270, 320, 35, 1013016, false, false); // A spyglass
 
                AddButton(46, 303, 0xFA5, 0xFA7, 6, GumpButtonType.Reply, 0);
                AddHtmlLocalized(80, 305, 320, 35, 1013017, false, false); // Dyes and a dye tub
 
                AddButton(120, 340, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0);
                AddHtmlLocalized(154, 342, 100, 35, 1011012, false, false); // CANCEL
            }
 
            public override void OnResponse(NetState sender, RelayInfo info)
            {
                if (m_Ticket.Deleted)
                    return;
 
                int number = 0;
 
                Item item = null;
                Item item2 = null;
 
                switch (info.ButtonID)
                {
                    case 1: item = new Bandage(100); "100 bandages have been placed in your backpack"; break; // A sextant has been placed in your backpack.
                    case 2: item = new HairRestylingDeed(); number = 501933; break; // A coupon for a free hair restyling has been placed in your backpack.
                    case 3: item = new Spellbook(0xFFFFFFFF); number = 1010495; break; // A spellbook with all 1st to 4th circle spells has been placed in your backpack.
                    case 4: item = new FireworksWand(); number = 501935; break; // A wand of fireworks has been placed in your backpack.
                    case 5: item = new Spyglass(); number = 501936; break; // A spyglass has been placed in your backpack.
                    case 6: item = new DyeTub(); item2 = new Dyes(); number = 501937; break; // The dyes and dye tub have been placed in your backpack.
                }
 
                if (item != null)
                {
                    m_Ticket.Delete();
 
                    m_From.SendLocalizedMessage(number);
                    m_From.AddToBackpack(item);
 
                    if (item2 != null)
                        m_From.AddToBackpack(item2);
                }
            }
        }
    }
}
 

Alyssa Dark

Sorceror
Here's a section from a gump we have on a custom deed, that uses AddLabel instead of AddHtmlLocalized.... though yours has 7 arguments for the Localized message while ours has 4 for the Label... I'm not familiar with gumps enough to know right off what all those arguments are for so I'm not going to make a suggestion on what you'd actually need for yours to work. I believe the 4 on ours is for x position, y position, hue and the label itself. This is just a reference that will hopefully help. :)

Code:
        AddLabel( 52, 40, 0, "Crusader Bracelet" );
        AddButton( 12, 40, 4005, 4007, 8, GumpButtonType.Reply, 1 );
        AddLabel( 52, 60, 0, "Crusader Ring" );
        AddButton( 12, 60, 4005, 4007, 10, GumpButtonType.Reply, 2 );
        AddLabel( 52, 80, 0, "Crusader Earrings" );
        AddButton( 12, 80, 4005, 4007, 9, GumpButtonType.Reply, 3 );
 

ThatDudeJBob

Sorceror
AddHtmlLocalized Refers to a Cliloc
C#:
AddHtmlLocalized(80, 270, 320, 35, 1013016, false, false); // A spyglass
Cliloc 1013016 being "A spyglass"

----------------------------------------

AddHtml Refers to "Anything you want to say in quotes"
C#:
AddHtml(80, 270, 320, 35, "A Spyglass", false, false); // A spyglass
 
Top