Lena80

Member
Hello im trying to give a player a helmet

What would be the way to give the player an item then automatically equip it?


1- Give the item
2 - Check if the item is not null
3 - Equip the item ??

Thanks
 
U should check the item is null or not very first to avoid any crashes. But anyway if you want to check it after giving it should look like this but it will do adding to backpack and equiping very fast which is not able to see in backpack.
Code:
 public override void OnDoubleClick(Mobile from)
        {
            base.OnDoubleClick(from);
            PlayerMobile player = from as PlayerMobile;
            Helmet helm = new Helmet();
          
                player.AddToBackpack(helm);
            if (helm != null)
            {
                player.EquipItem(helm);
            }
        }

If you want to add delay between these two actions , you can use Timer class. Basically , create a custom timer class and give it's onTick method to equipItem method. If you couldn't do that , feel free to reply to me for writing it ^^
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back