ServUO Version
Publish Unknown
Ultima Expansion
Mondain's Legacy
My shard is using RunUO Version 2.1, Build 6905.732
Core: Running on .NET Framework Version 4.0.30319
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

I have been working on this off and on for a week now and have no more ideas if/how I can make it work.

I am trying to use 'OnSingleClick' to give house owners the ability to change an item's ItemID.

The reason I want to do this is because I already have 'OnDoubleClick' doing something different.

Here are my latest Errors:
Code:
Errors:
    CS0201: Line 449: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
    CS0201: Line 456: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement

and . . here is my 'OnSingleClick' section.
Code:
        public virtual void OnSingleClick( Mobile from, Item item  )
        {
            BaseHouse house = BaseHouse.FindHouseAt( from );
            if ( house != null && house.IsOwner( from ) )
            {
                if ( Deleted || !from.CanSee( this ) )
                    return;

                NetState ns = from.NetState;

                if ( ns != null )
                {
                    // Regular east facing bookcase
                    if ( this.ItemID == 0xA99 )
                    {
                        this.ItemID == 0xC15; 
                        from.SendMessage("You change the style to a ruined bookcase.");
                        return;
                    }
                    // Regular east facing bookcase
                    else if ( this.ItemID == 0xC15 )
                    {
                        this.ItemID == 0xA99; 
                        from.SendMessage("You change the style to a regular bookcase.");
                        return;
                    }
                }
            }
        }

Is what I am trying even possible using 'OnSingleClick'? I so, can anyone tell me what I am doing wrong?

Would really appreciate help with this one.

Many Thanks
 
Thank you for your fast reply Pyro.
I have to admit my ignorance now because sadly . . Sorry, but I don't know what you mean by 'use 1 = sign not 2'.
I did searches on C# and 'sign' but they seem related to strings, so I'm missing the boat on it.
 
When you use
Code:
 ==
you are comparing two values if they are equal, and when you assign a property, field etc etc, you use
Code:
 =
you can't assign using the comparator!

Check out for more info : C# operators and expressions - List all C# operators and expression

Wrong Usage
Code:
this.ItemID == 0xC15;

Correct Usage (you don't need to use 'this' when within the class, only when passing onto methods and such, just a tip)
Code:
ItemID = 0xC15;
 
Hi Kita

OMG . . (copy + paste + 'bad eyes' = the lose). Thank you for reminding a newb the importance of reading what we type.

I fixed the == vs = problem and re-tried with and without the 'this' . . everything compiles fine but the ItemID is not applied so the graphic for the item does not change.

Is this because it's not something that can be done using 'OnSingleClick' ?
 
Thank you again.

I spent the last couple hours trying many variations on this. I get it to compile with not errors but when (in-game) I 'Single Click' on the item nothing happens (it does not change from one ItmID to another ItemID.

Here is my latest try Kita:
Code:
        public override void OnSingleClick( Mobile from )
        {
            BaseHouse house = BaseHouse.FindHouseAt( from );
            if ( house != null && house.IsOwner( from ) )
            {
                if ( Deleted || !from.CanSee( this ) )
                    return;

                // Regular east facing bookcase
                if ( ItemID == 0xA99 )
                {
                    ItemID = 0xC15; 
                    from.SendMessage("You change the style to a ruined bookcase.");
                }

                // Regular east facing bookcase
                else if ( ItemID == 0xC15 )
                {
                    ItemID = 0xA99; 
                    from.SendMessage("You change the style to a regular bookcase.");
                }
            }
            base.OnSingleClick( from );
        }

Have to say, I appreciate your time looking at this. I'm looking pretty bad at solving this and wondering if 'Single Click' is capable of doing this kind of thing.

Sorry for using up your time on it.
 
I know the single click works as it brings up the context menu on items with that feature, I havn't look at this for a bit but thinking you might need to use that method and add a call that way!

Example
Code:
        public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
        {
            base.GetContextMenuEntries(from, list);

            if (RootParent == from && from.Alive && Movable)
                list.Add(new AddToEntry());
        }

Code:
internal class AddToEntry : ContextMenuEntry
    {
        public AddToEntry() : base(1115891, 3) // link (Find a local that better fits your call)
        {
        }

        public override void OnClick()
        {
            if (Owner.From.CheckAlive())
            {
                Owner.From.Target = new BookCaseTarget();
            }
        }

        private class BookCaseTarget : Target
        {

            public BookCaseTarget() : base(3, false, TargetFlags.None)
            {
            }

            protected override void OnTarget(Mobile from, object targeted)
            {
                if (targeted is BOOKCASENAME case)
                {
                    if (from.CheckAlive() && !case.Deleted && case.Movable && case.CheckItemUse(from))
                    {
                      
// Regular east facing bookcase
                if ( case.ItemID == 0xA99 )
                {
                    case.ItemID = 0xC15;
                    from.SendMessage("You change the style to a ruined bookcase.");
                }
                 else
                  {
                          case.ItemID = 0xA99;
                          from.SendMessage("You change the style to a regular bookcase.");
                    }
                    }
                }
            }
        }
 
Back