Full Version : UniversalDyeTub Question
xmlspawner >>Scripting Support >>UniversalDyeTub Question


<< Prev | Next >>

Erica- 07-05-2006
Hi ok as you see i use a universal dye tub it dyes anything except pets what i want it to do is not dye gold and tokens and silver is there anyway to add a line for this not to dye gold and tokens and silver if so where would i add this line on it heres the script.
CODE
using System;
using Server;
using Server.Targeting;
using Server.Items;

namespace Server.Items
{

public class UnivTubTarget : Target
{
private Item m_Item;

public UnivTubTarget( Item item ) : base( 12, false, TargetFlags.None )
{
m_Item = item;
}

protected override void OnTarget( Mobile from, object targeted )
{
if ( targeted is Item )
{
Item targ = (Item)targeted;
if ( !targ.IsChildOf (from.Backpack))
{
from.SendMessage( "The item is not in your pack!" );
}
else
{
targ.Hue=m_Item.Hue;
from.PlaySound( 0x23F );
}
}

}
}


public class UniversalDyeTub : DyeTub
{
 public override CustomHuePicker CustomHuePicker{ get{ return CustomHuePicker.UniversalDyeTub; } }
private bool m_Redyable;


[Constructable]
public UniversalDyeTub()
{
Weight = 0.0;
Hue = 0;
Name = "Universal Dye Tub";
m_Redyable = true;
}

public UniversalDyeTub( Serial serial ) : base( serial )
{
}

public override void OnDoubleClick( Mobile from )
{

if ( !IsChildOf (from.Backpack))
{
from.Target = new UnivTubTarget( this );
from.SendMessage( "What do you wish to dye?" );
}
else
{
from.Target = new UnivTubTarget( this );
from.SendMessage( "What do you wish to dye?" );

}

}




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();
}
}
}


ArteGordon- 07-05-2006
change this

CODE

protected override void OnTarget( Mobile from, object targeted )
{
if ( targeted is Item )


to this

CODE

protected override void OnTarget( Mobile from, object targeted )
{
if ( targeted is Item && !(targeted is Gold) && !(targeted is Token) && !(targeted is Silver))


I'm guessing at the exact class names of the things you want to protect. You need to change Gold, Token, and Silver to your actual types.

Erica- 07-05-2006
Ok thanks it works had to put on top using Server.Factions; for it to complie since silver is from faction do have one more question ok it wont dye the gold, tokens and silver so would like it to say a message something like you can not dye this item so what should i put for that cause cant dye them but doesnt say nothing at all.

ArteGordon- 07-05-2006
CODE

protected override void OnTarget(Mobile from, object targeted)
 {
  if ( targeted is Item && !(targeted is Gold) && !(targeted is Token) && !(targeted is Silver))
  {
   Item targ = (Item)targeted;
   if (!targ.IsChildOf(from.Backpack))
   {
    from.SendMessage("The item is not in your pack!");
   }
   else
   {
    targ.Hue = m_Item.Hue;
    from.PlaySound(0x23F);
   }
  }
  else
  {
   from.SendMessage("You cannot dye that.");
  }

 }