public static void GiveItem(Mobile from, Item item, int amount, bool CopyProperties, int give, int access) { bool done = true; if ( give == (int)AddToBankGump.Switches.GiveToAccount ) { done = AddToBank.GiveItemToAccounts(item, amount, CopyProperties); } else if ( give == (int)AddToBankGump.Switches.GiveToCharacter ) { done = AddToBank.GiveItemToCharacters(item, amount, CopyProperties); } else if ( give == (int)AddToBankGump.Switches.GiveToAccessLevel ) { done = AddToBank.GiveItemToAccessLevel(item, amount, CopyProperties, access); } if ( !done ) { from.SendMessage( "Unable to give out to 1 or more players." ); } else { from.SendMessage( "Completed." ); } }
public override void OnResponse(Server.Network.NetState sender, RelayInfo info) { Mobile from = sender.Mobile; string TypeName = string.Empty; int GiveRule = 0; int Access = 0; int CopyProperties = 0; foreach( int sw in info.Switches ) { switch ( sw ) { case (int)Switches.GiveToCharacter: { GiveRule = (int)Switches.GiveToCharacter; break; } case (int)Switches.GiveToAccount: { GiveRule = (int)Switches.GiveToAccount; break; } case (int)Switches.GiveToAccessLevel: { GiveRule = (int)Switches.GiveToAccessLevel; break; } case (int)Switches.CopyProperties: { CopyProperties = (int)Switches.CopyProperties; break; } case (int)Switches.Owner: case (int)Switches.Administrator: case (int)Switches.Seer: case (int)Switches.GameMaster: case (int)Switches.Counselor: case (int)Switches.FightBroker: case (int)Switches.Reporter: { Access += sw; break; } } } if ( GiveRule == 0 ) { from.SendMessage( "You must select the audience rule to receive the item." ); from.SendGump( new AddToBankGump( GiveRule, Access, TypeName, m_Amount ) ); return; } else if ( GiveRule == (int)Switches.GiveToAccessLevel && Access == 0 ) { from.SendMessage( "You must select the AccessLevel to receive the item." ); from.SendGump( new AddToBankGump( GiveRule, Access, TypeName, m_Amount ) ); return; } switch( info.ButtonID ) { case (int)Buttons.GiveByTarget: { from.Target = new AddToBank.DupeTarget(false, m_Amount, CopyProperties != 0, GiveRule, Access); from.SendMessage( "What do you wish to give out?" ); break; } case (int)Buttons.GiveByType: { if ( info.TextEntries.Length > 0 ) { TypeName = info.TextEntries[0].Text; } if ( TypeName == string.Empty ) { from.SendMessage( "You must specify a type" ); from.SendGump( new AddToBankGump( GiveRule, Access, TypeName, m_Amount ) ); } else { Type type = ScriptCompiler.FindTypeByName( TypeName, true ); if ( type == null ) { from.SendMessage( "{0} is not a valid type", type ); from.SendGump( new AddToBankGump( GiveRule, Access, string.Empty, m_Amount ) ); return; } else { object obj = Activator.CreateInstance( type ); if ( obj is Item ) AddToBank.GiveItem( from, (Item)obj, m_Amount, CopyProperties != 0,GiveRule, Access ); else { from.SendMessage( "You may only duplicate items." ); } } } break; } case (int)Buttons.IncAmount: { from.SendGump( new AddToBankGump( GiveRule, Access, TypeName, ++m_Amount ) ); break; } case (int)Buttons.DecAmount: { if ( m_Amount > 1 ) m_Amount -= 1; else from.SendMessage( "You cannot give less than 1 item." ); from.SendGump( new AddToBankGump( GiveRule, Access, TypeName, m_Amount ) ); break; } } }