Worn Equipment not functioning on login

HalfMercy2

Member
Oct 21, 2018
12
0
33
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:
using System;
using Server;
using Server.Items;
using Server.Mobiles;
using Server.Gumps;
using Server.Network;
using System.Collections;


namespace Server.Items
{
   [FlipableAttribute(0x170b, 0x170c)]
   public class Speedboots : BaseShoes
   {
	private bool b_SpeedIncrease = true;
	[CommandProperty(AccessLevel.GameMaster)]
	public bool SpeedIncrease { get { return b_SpeedIncrease; } set { b_SpeedIncrease = value; InvalidateProperties(); } }

      [Constructable]
      public Speedboots() : base(0x170b)
      {
         Weight = 1.0;
         Hue = 0x501;
         Name = "Boots of Speed";
         Layer = Layer.Shoes;
      }

      public override void GetProperties(ObjectPropertyList list)
      {
          base.GetProperties(list);

          if(SpeedIncrease)
          list.Add(1070809);
      }
  
  
      public override bool OnEquip(Mobile from)
      {
          base.OnEquip(from);

          if(SpeedIncrease)
          {
          PlayerMobile pm = from as PlayerMobile;
          pm.Send(SpeedControl.MountSpeed);
          }

      
      

          return true;
      }

      private static void World_Login( LoginEventArgs args )
      {
          if ( args.Mobile != null )
          {
              Item item = args.Mobile.FindItemOnLayer( Layer.Shoes );
              if( item != null )
              {
                  if(item is Speedboots && ((Speedboots)item).SpeedIncrease)
                          args.Mobile.Send(SpeedControl.MountSpeed);
              }
          }
      }

      public override void OnRemoved(object parent)
      {
          base.OnRemoved(parent);
          Mobile from;
          from = parent as Mobile;
          PlayerMobile pm = from as PlayerMobile;
    

          if (parent is Mobile)
          {
              from = parent as Mobile;
          
                  pm.Send(SpeedControl.Disable);

          
          

          }
      }


      public Speedboots(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();
      }
   }
}
 
Last edited:

NMND

Member
Dec 25, 2018
20
2
31
NGFR, Djurmannee
Shard Name
Ardenreich
Donate
Donate money to this user
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
 

HalfMercy2

Member
Oct 21, 2018
12
0
33
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.
 

PyrO

Well-Known Member
Jan 27, 2015
1,089
77
Well since nothing actually calls that method I would assume ;)

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

Code:
		public static void Configure()
		{
			EventSink.Login += World_Login;
		}
 

HalfMercy2

Member
Oct 21, 2018
12
0
33
Well since nothing actually calls that method I would assume ;)

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

Code:
		public static void Configure()
		{
			EventSink.Login += World_Login;
		}

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

Fireball

Well-Known Member
Sep 6, 2014
151
10
United Kingdom
uoutopia.com
Shard Name
UO:Utopia
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"
 
Last edited:

PyrO

Well-Known Member
Jan 27, 2015
1,089
77
World_Login is the method he already had in his code, but it wasnt used

Code:
      private static void World_Login( LoginEventArgs args )
      {
          if ( args.Mobile != null )
          {
              Item item = args.Mobile.FindItemOnLayer( Layer.Shoes );
              if( item != null )
              {
                  if(item is Speedboots && ((Speedboots)item).SpeedIncrease)
                          args.Mobile.Send(SpeedControl.MountSpeed);
              }
          }
      }