1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Worn Equipment not functioning on login

Discussion in 'Script Support' started by HalfMercy2, Dec 25, 2018.

  1. HalfMercy2
    Offline

    HalfMercy2 New Member

    Joined:
    Oct 21, 2018
    Messages:
    12
    Likes Received:
    0
    For ServUO server, 10/30/18 downloaded

    I don't claim credit for the base script but I last used it July 2016, so I no longer remember where I may have picked it up from. I was in the habit of using pre-existing scripts from RunUO and trying to tweak them as a way of learning.

    This script is simply for boots that enable the wearer to run on foot at the same speed as they would if mounted. That part works fine. But what has never worked, not in 2016 and not today, is logging in with a character already wearing the boots and being able to run at mount speed right away. Instead, the boots need to be unequipped and then re-equipped before they start working. Can someone help me troubleshoot and fix?

    Speedboots.cs
    ---------------------
    Code (C#):
    1. using System;
    2. using Server;
    3. using Server.Items;
    4. using Server.Mobiles;
    5. using Server.Gumps;
    6. using Server.Network;
    7. using System.Collections;
    8.  
    9.  
    10. namespace Server.Items
    11. {
    12.    [FlipableAttribute(0x170b, 0x170c)]
    13.    public class Speedboots : BaseShoes
    14.    {
    15.     private bool b_SpeedIncrease = true;
    16.     [CommandProperty(AccessLevel.GameMaster)]
    17.     public bool SpeedIncrease { get { return b_SpeedIncrease; } set { b_SpeedIncrease = value; InvalidateProperties(); } }
    18.  
    19.       [Constructable]
    20.       public Speedboots() : base(0x170b)
    21.       {
    22.          Weight = 1.0;
    23.          Hue = 0x501;
    24.          Name = "Boots of Speed";
    25.          Layer = Layer.Shoes;
    26.       }
    27.  
    28.       public override void GetProperties(ObjectPropertyList list)
    29.       {
    30.           base.GetProperties(list);
    31.  
    32.           if(SpeedIncrease)
    33.           list.Add(1070809);
    34.       }
    35.  
    36.  
    37.       public override bool OnEquip(Mobile from)
    38.       {
    39.           base.OnEquip(from);
    40.  
    41.           if(SpeedIncrease)
    42.           {
    43.           PlayerMobile pm = from as PlayerMobile;
    44.           pm.Send(SpeedControl.MountSpeed);
    45.           }
    46.  
    47.      
    48.      
    49.  
    50.           return true;
    51.       }
    52.  
    53.       private static void World_Login( LoginEventArgs args )
    54.       {
    55.           if ( args.Mobile != null )
    56.           {
    57.               Item item = args.Mobile.FindItemOnLayer( Layer.Shoes );
    58.               if( item != null )
    59.               {
    60.                   if(item is Speedboots && ((Speedboots)item).SpeedIncrease)
    61.                           args.Mobile.Send(SpeedControl.MountSpeed);
    62.               }
    63.           }
    64.       }
    65.  
    66.       public override void OnRemoved(object parent)
    67.       {
    68.           base.OnRemoved(parent);
    69.           Mobile from;
    70.           from = parent as Mobile;
    71.           PlayerMobile pm = from as PlayerMobile;
    72.    
    73.  
    74.           if (parent is Mobile)
    75.           {
    76.               from = parent as Mobile;
    77.          
    78.                   pm.Send(SpeedControl.Disable);
    79.  
    80.          
    81.          
    82.  
    83.           }
    84.       }
    85.  
    86.  
    87.       public Speedboots(Serial serial)
    88.           : base(serial)
    89.       {
    90.  
    91.       }
    92.  
    93.       public override void Serialize( GenericWriter writer )
    94.       {
    95.          base.Serialize( writer );
    96.          writer.Write( (int) 0 ); // version
    97.       }
    98.  
    99.       public override void Deserialize( GenericReader reader )
    100.       {
    101.          base.Deserialize( reader );
    102.          int version = reader.ReadInt();
    103.       }
    104.    }
    105. }
     
    #1 HalfMercy2, Dec 25, 2018
    Last edited: Dec 26, 2018
  2. NMND
    Offline

    NMND New Member

    Joined:
    Dec 25, 2018
    Messages:
    20
    Likes Received:
    2
    Would you mind using the [ code ] tags around your code? Just for better readability, so people with the skills to help you don't get annoyed. :)

    Thanks!
    -The Formatting-Piggy
     
  3. HalfMercy2
    Offline

    HalfMercy2 New Member

    Joined:
    Oct 21, 2018
    Messages:
    12
    Likes Received:
    0
    Sure; as a new guy I didn't realize that was a thing. :)

    Also, since posting I've realized that the original script I used was called "fastfeet" and I edited out many parts involving special effects, if that helps anything. I believe the part about privatestaticvoid World_Login( LoginEventArgs args ) is supposed to cover logging in and the boots functioning right away without being unequipped, but it doesn't and never did.
     
    • Thanks! Thanks! x 1
  4. PyrO
    Offline

    PyrO Well-Known Member

    Joined:
    Jan 27, 2015
    Messages:
    1,023
    Likes Received:
    53
    Well since nothing actually calls that method I would assume ;)

    Add this in your script and tell me how it does :D

    Code (C#):
    1.         public static void Configure()
    2.         {
    3.             EventSink.Login += World_Login;
    4.         }
     
    • Thanks! Thanks! x 1
  5. HalfMercy2
    Offline

    HalfMercy2 New Member

    Joined:
    Oct 21, 2018
    Messages:
    12
    Likes Received:
    0

    Haha... no great surprise, it worked like a charm :) Thank you for the help!
     
  6. Fireball
    Offline

    Fireball Member

    Joined:
    Sep 6, 2014
    Messages:
    144
    Likes Received:
    8
    Thank you PyrO, this will likely fix a problem I had with an item of clothing too!

    My fix was to add a check for the item in PlayerMobile OnLogin to remove and re-equip it but your method is much cleaner.

    Except World_Login doesn't appear to exist for me. Where is it please?

    "The name 'World_Login' does not exist in the current context"
     
    #6 Fireball, Jan 11, 2019
    Last edited: Jan 11, 2019
  7. PyrO
    Offline

    PyrO Well-Known Member

    Joined:
    Jan 27, 2015
    Messages:
    1,023
    Likes Received:
    53
    World_Login is the method he already had in his code, but it wasnt used

    Code (C#):
    1.       private static void World_Login( LoginEventArgs args )
    2.       {
    3.           if ( args.Mobile != null )
    4.           {
    5.               Item item = args.Mobile.FindItemOnLayer( Layer.Shoes );
    6.               if( item != null )
    7.               {
    8.                   if(item is Speedboots && ((Speedboots)item).SpeedIncrease)
    9.                           args.Mobile.Send(SpeedControl.MountSpeed);
    10.               }
    11.           }
    12.       }
     
  8. Fireball
    Offline

    Fireball Member

    Joined:
    Sep 6, 2014
    Messages:
    144
    Likes Received:
    8
    LoL. I see it now thanks :)
     
Similar Threads: Worn Equipment
Forum Title Date
Custom Releases Battle Worn Vecna Set Mar 23, 2018
Script Support What attribute is the location of equipment? Oct 24, 2018
Support Equipment Sets Causing Crash Jun 7, 2018
Script Support gargish equipment dont drop in Termur as loot, exxept shields Dec 18, 2015
Script Support Checking for equipment on Playermobile Jul 5, 2015
Custom Releases Colored Equipment Names Apr 22, 2015
Quests Quest for beginner equipment(Human) Dec 4, 2013