From 2b38d0987f751129baf186c2c36debfc1780c811 Mon Sep 17 00:00:00 2001 From: Christopher Date: Sat, 11 Jul 2020 14:34:47 +0200 Subject: [PATCH] add osRemoveAllAttachmentsFromAvatar() --- src/Appearance2Avatar.cs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/Appearance2Avatar.cs b/src/Appearance2Avatar.cs index d9813fe..aacd43a 100644 --- a/src/Appearance2Avatar.cs +++ b/src/Appearance2Avatar.cs @@ -61,6 +61,7 @@ namespace OpenSim.Modules.Appearance2Avatar m_scriptModule = scene.RequestModuleInterface(); if (m_scriptModule != null) { + m_scriptModule.RegisterScriptInvocation(this, "osRemoveAllAttachmentsFromAvatar"); m_scriptModule.RegisterScriptInvocation(this, "osAppearance2Avatar"); } @@ -74,6 +75,39 @@ namespace OpenSim.Modules.Appearance2Avatar } + [ScriptInvocation] + public void osRemoveAllAttachmentsFromAvatar(UUID hostID, UUID scriptID, String targetAvatar) + { + ScenePresence sp = m_scene.GetScenePresence(UUID.Parse(targetAvatar)); + + if (sp != null) + { + //Remove all attachments + List _allAttachments = sp.GetAttachments(); + foreach (SceneObjectGroup _attachment in _allAttachments) + m_scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, _attachment); + + if (m_scene.AttachmentsModule != null) + m_scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, false); + + //Remove current outfit from inventory + InventoryFolderBase _outfitFolder = m_scene.InventoryService.GetFolderForType(sp.UUID, FolderType.CurrentOutfit); + + if (_outfitFolder != null) + { + InventoryCollection _outfitFolderContend = m_scene.InventoryService.GetFolderContent(sp.UUID, _outfitFolder.ID); + + List _itemIDs = new List(); + foreach (InventoryItemBase item in _outfitFolderContend.Items) + if (item.InvType == (int)AssetType.Object) + _itemIDs.Add(item.ID); + + m_scene.InventoryService.DeleteItems(sp.UUID, _itemIDs); + m_scene.InventoryService.UpdateFolder(_outfitFolder); + } + } + } + [ScriptInvocation] public void osAppearance2Avatar(UUID hostID, UUID scriptID, String notecard, String targetAvatar) {