Iomega0318

Member
Ultima Expansion
Endless Journey
Working on something and wanted to know a better was to write the following piece of code, I tried looking at a few other scripts that add +1 to certain things but none of them worked the way I was expecting them to work. Essentially this just needs to add +1 to the tag all the way up to 7 but not past. Let me know, thank you.

C#:
            if (IsChildOf(from.Backpack))
            {
                if (chars < 2)
                {
                    from.SendLocalizedMessage(1049512); // You feel a surge of magic as the scroll enhances your powers!

                    acct.SetTag("maxChars", "02");

                    from.PlaySound(0x1EA);
                    from.FixedEffect(0x373A, 10, 15);

                    Delete();
                }
                else if (chars < 3)
                {
                    from.SendLocalizedMessage(1049512); // You feel a surge of magic as the scroll enhances your powers!

                    acct.SetTag("maxChars", "03");

                    from.PlaySound(0x1EA);
                    from.FixedEffect(0x373A, 10, 15);

                    Delete();
                }
                else if (chars < 4)
                {
                    from.SendLocalizedMessage(1049512); // You feel a surge of magic as the scroll enhances your powers!

                    acct.SetTag("maxChars", "04");

                    from.PlaySound(0x1EA);
                    from.FixedEffect(0x373A, 10, 15);

                    Delete();
                }
                else if (chars < 5)
                {
                    from.SendLocalizedMessage(1049512); // You feel a surge of magic as the scroll enhances your powers!

                    acct.SetTag("maxChars", "05");

                    from.PlaySound(0x1EA);
                    from.FixedEffect(0x373A, 10, 15);

                    Delete();
                }
                else if (chars < 6)
                {
                    from.SendLocalizedMessage(1049512); // You feel a surge of magic as the scroll enhances your powers!

                    acct.SetTag("maxChars", "06");

                    from.PlaySound(0x1EA);
                    from.FixedEffect(0x373A, 10, 15);

                    Delete();
                }
                else if (chars < 7)
                {
                    from.SendLocalizedMessage(1049512); // You feel a surge of magic as the scroll enhances your powers!

                    acct.SetTag("maxChars", "07");

                    from.PlaySound(0x1EA);
                    from.FixedEffect(0x373A, 10, 15);

                    Delete();
                }
                else if (chars >= 7)
                {
                    from.SendMessage("Your character slots are too high for this scroll."); // Your control slots are too high for this power scroll.
                }
            }
            else
            {
                from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
            }
 
C#:
public override void OnDoubleClick(Mobile from)
{
    if (IsChildOf(from.Backpack))
    {
        var acct = (Account)from.Account;
        var chars = Utility.ToInt32(acct.GetTag("maxChars"));

        if (chars < 7)
        {
            from.SendLocalizedMessage(1049512); // You feel a surge of magic as the scroll enhances your powers!

            acct.SetTag("maxChars", (chars + 1).ToString());

            from.PlaySound(0x1EA);
            from.FixedEffect(0x373A, 10, 15);

            Delete();
        }
        else 
        {
            from.SendMessage("Your character slots are too high for this scroll."); 
        }
    }
    else
    {
        from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
    }
}
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back