public ResetIDs ( UUID partID ) : void | ||
partID | UUID | The new part ID to which this item belongs |
return | void |
/// <summary> /// Rez a script into a prim's inventory, either ex nihilo or from an existing avatar inventory /// </summary> /// <param name="remoteClient"></param> /// <param name="itemID"> </param> /// <param name="localID"></param> public void RezScript(IClientAPI remoteClient, InventoryItemBase itemBase, UUID transactionID, uint localID) { UUID itemID = itemBase.ID; UUID copyID = UUID.Random(); if (itemID != UUID.Zero) // transferred from an avatar inventory to the prim's inventory { InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); item = InventoryService.GetItem(item); // Try library // XXX clumsy, possibly should be one call if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null) { item = LibraryService.LibraryRootFolder.FindItem(itemID); } if (item != null) { SceneObjectPart part = GetSceneObjectPart(localID); if (part != null) { if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) return; part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID); part.Inventory.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0); // m_log.InfoFormat("[PRIMINVENTORY]: " + // "Rezzed script {0} into prim local ID {1} for user {2}", // item.inventoryName, localID, remoteClient.Name); part.GetProperties(remoteClient); part.ParentGroup.ResumeScripts(); } else { m_log.ErrorFormat( "[PRIM INVENTORY]: " + "Could not rez script {0} into prim local ID {1} for user {2}" + " because the prim could not be found in the region!", item.Name, localID, remoteClient.Name); } } else { m_log.ErrorFormat( "[PRIM INVENTORY]: Could not find script inventory item {0} to rez for {1}!", itemID, remoteClient.Name); } } else // script has been rezzed directly into a prim's inventory { SceneObjectPart part = GetSceneObjectPart(itemBase.Folder); if (part == null) return; if (!Permissions.CanCreateObjectInventory( itemBase.InvType, part.UUID, remoteClient.AgentId)) return; AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, Encoding.ASCII.GetBytes(DefaultLSLScript), remoteClient.AgentId); AssetService.Store(asset); TaskInventoryItem taskItem = new TaskInventoryItem(); taskItem.ResetIDs(itemBase.Folder); taskItem.ParentID = itemBase.Folder; taskItem.CreationDate = (uint)itemBase.CreationDate; taskItem.Name = itemBase.Name; taskItem.Description = itemBase.Description; taskItem.Type = itemBase.AssetType; taskItem.InvType = itemBase.InvType; taskItem.OwnerID = itemBase.Owner; taskItem.CreatorID = itemBase.CreatorIdAsUuid; taskItem.BasePermissions = itemBase.BasePermissions; taskItem.CurrentPermissions = itemBase.CurrentPermissions; taskItem.EveryonePermissions = itemBase.EveryOnePermissions; taskItem.GroupPermissions = itemBase.GroupPermissions; taskItem.NextPermissions = itemBase.NextPermissions; taskItem.GroupID = itemBase.GroupID; taskItem.GroupPermissions = 0; taskItem.Flags = itemBase.Flags; taskItem.PermsGranter = UUID.Zero; taskItem.PermsMask = 0; taskItem.AssetID = asset.FullID; taskItem.SalePrice = itemBase.SalePrice; taskItem.SaleType = itemBase.SaleType; part.Inventory.AddInventoryItem(taskItem, false); part.GetProperties(remoteClient); part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); part.ParentGroup.ResumeScripts(); } }
/// <summary> /// Save a notecard to prim inventory. /// </summary> /// <param name="name"></param> /// <param name="description">Description of notecard</param> /// <param name="notecardData"></param> /// <param name="forceSameName"> /// If true, then if an item exists with the same name, it is replaced. /// If false, then a new item is created witha slightly different name (e.g. name 1) /// </param> /// <returns>Prim inventory item created.</returns> protected TaskInventoryItem SaveNotecard(string name, string description, string data, bool forceSameName) { // Create new asset AssetBase asset = new AssetBase(UUID.Random(), name, (sbyte)AssetType.Notecard, m_host.OwnerID.ToString()); asset.Description = description; byte[] a; byte[] b; byte[] c; b = Util.UTF8.GetBytes(data); a = Util.UTF8.GetBytes( "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length " + b.Length.ToString() + "\n"); c = Util.UTF8.GetBytes("}"); byte[] d = new byte[a.Length + b.Length + c.Length]; Buffer.BlockCopy(a, 0, d, 0, a.Length); Buffer.BlockCopy(b, 0, d, a.Length, b.Length); Buffer.BlockCopy(c, 0, d, a.Length + b.Length, c.Length); asset.Data = d; World.AssetService.Store(asset); // Create Task Entry TaskInventoryItem taskItem = new TaskInventoryItem(); taskItem.ResetIDs(m_host.UUID); taskItem.ParentID = m_host.UUID; taskItem.CreationDate = (uint)Util.UnixTimeSinceEpoch(); taskItem.Name = name; taskItem.Description = description; taskItem.Type = (int)AssetType.Notecard; taskItem.InvType = (int)InventoryType.Notecard; taskItem.OwnerID = m_host.OwnerID; taskItem.CreatorID = m_host.OwnerID; taskItem.BasePermissions = (uint)PermissionMask.All | (uint)PermissionMask.Export; taskItem.CurrentPermissions = (uint)PermissionMask.All | (uint)PermissionMask.Export; taskItem.EveryonePermissions = 0; taskItem.NextPermissions = (uint)PermissionMask.All; taskItem.GroupID = m_host.GroupID; taskItem.GroupPermissions = 0; taskItem.Flags = 0; taskItem.PermsGranter = UUID.Zero; taskItem.PermsMask = 0; taskItem.AssetID = asset.FullID; if (forceSameName) m_host.Inventory.AddInventoryItemExclusive(taskItem, false); else m_host.Inventory.AddInventoryItem(taskItem, false); return taskItem; }
// ----------------------------------------------------------------- /// <summary> /// /// </summary> // ----------------------------------------------------------------- private void DoJsonWriteNotecard(UUID reqID, UUID hostID, UUID scriptID, UUID storeID, string path, string name) { string data; if (! m_store.GetValue(storeID,path,true, out data)) { m_comms.DispatchReply(scriptID,0,UUID.Zero.ToString(),reqID.ToString()); return; } SceneObjectPart host = m_scene.GetSceneObjectPart(hostID); // Create new asset UUID assetID = UUID.Random(); AssetBase asset = new AssetBase(assetID, name, (sbyte)AssetType.Notecard, host.OwnerID.ToString()); asset.Description = "Json store"; int textLength = data.Length; data = "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length " + textLength.ToString() + "\n" + data + "}\n"; asset.Data = Util.UTF8.GetBytes(data); m_scene.AssetService.Store(asset); // Create Task Entry TaskInventoryItem taskItem = new TaskInventoryItem(); taskItem.ResetIDs(host.UUID); taskItem.ParentID = host.UUID; taskItem.CreationDate = (uint)Util.UnixTimeSinceEpoch(); taskItem.Name = asset.Name; taskItem.Description = asset.Description; taskItem.Type = (int)AssetType.Notecard; taskItem.InvType = (int)InventoryType.Notecard; taskItem.OwnerID = host.OwnerID; taskItem.CreatorID = host.OwnerID; taskItem.BasePermissions = (uint)PermissionMask.All; taskItem.CurrentPermissions = (uint)PermissionMask.All; taskItem.EveryonePermissions = 0; taskItem.NextPermissions = (uint)PermissionMask.All; taskItem.GroupID = host.GroupID; taskItem.GroupPermissions = 0; taskItem.Flags = 0; taskItem.PermsGranter = UUID.Zero; taskItem.PermsMask = 0; taskItem.AssetID = asset.FullID; host.Inventory.AddInventoryItem(taskItem, false); m_comms.DispatchReply(scriptID,1,assetID.ToString(),reqID.ToString()); }
/// <summary> /// Rez a new script from nothing with given script text. /// </summary> /// <param name="remoteClient"></param> /// <param name="itemBase">Template item.</param> /// <param name="scriptText"></param> /// <returns>The part where the script was rezzed if successful. False otherwise.</returns> public SceneObjectPart RezNewScript(UUID agentID, InventoryItemBase itemBase, string scriptText) { // The part ID is the folder ID! SceneObjectPart part = GetSceneObjectPart(itemBase.Folder); if (part == null) { // m_log.DebugFormat( // "[SCENE INVENTORY]: Could not find part with id {0} for {1} to rez new script", // itemBase.Folder, agentID); return null; } if (!Permissions.CanCreateObjectInventory(itemBase.InvType, part.UUID, agentID)) { // m_log.DebugFormat( // "[SCENE INVENTORY]: No permission to create new script in {0} for {1}", part.Name, agentID); return null; } AssetBase asset = CreateAsset( itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, Encoding.ASCII.GetBytes(scriptText), agentID); AssetService.Store(asset); TaskInventoryItem taskItem = new TaskInventoryItem(); taskItem.ResetIDs(itemBase.Folder); taskItem.ParentID = itemBase.Folder; taskItem.CreationDate = (uint)itemBase.CreationDate; taskItem.Name = itemBase.Name; taskItem.Description = itemBase.Description; taskItem.Type = itemBase.AssetType; taskItem.InvType = itemBase.InvType; taskItem.OwnerID = itemBase.Owner; taskItem.CreatorID = itemBase.CreatorIdAsUuid; taskItem.BasePermissions = itemBase.BasePermissions; taskItem.CurrentPermissions = itemBase.CurrentPermissions; taskItem.EveryonePermissions = itemBase.EveryOnePermissions; taskItem.GroupPermissions = itemBase.GroupPermissions; taskItem.NextPermissions = itemBase.NextPermissions; taskItem.GroupID = itemBase.GroupID; taskItem.GroupPermissions = 0; taskItem.Flags = itemBase.Flags; taskItem.PermsGranter = UUID.Zero; taskItem.PermsMask = 0; taskItem.AssetID = asset.FullID; part.Inventory.AddInventoryItem(taskItem, false); part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); // tell anyone managing scripts that a new script exists EventManager.TriggerNewScript(agentID, part, taskItem.ItemID); part.ParentGroup.ResumeScripts(); return part; }
// This needs ThreatLevel high. It is an excellent griefer tool, // In a loop, it can cause asset bloat and DOS levels of asset // writes. // public void osMakeNotecard(string notecardName, LSL_Types.list contents) { CheckThreatLevel(ThreatLevel.High, "osMakeNotecard"); m_host.AddScriptLPS(1); // Create new asset AssetBase asset = new AssetBase(UUID.Random(), notecardName, (sbyte)AssetType.Notecard, m_host.OwnerID.ToString()); asset.Description = "Script Generated Notecard"; string notecardData = String.Empty; for (int i = 0; i < contents.Length; i++) { notecardData += contents.GetLSLStringItem(i) + "\n"; } int textLength = notecardData.Length; notecardData = "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length " + textLength.ToString() + "\n" + notecardData + "}\n"; asset.Data = Util.UTF8.GetBytes(notecardData); World.AssetService.Store(asset); // Create Task Entry TaskInventoryItem taskItem=new TaskInventoryItem(); taskItem.ResetIDs(m_host.UUID); taskItem.ParentID = m_host.UUID; taskItem.CreationDate = (uint)Util.UnixTimeSinceEpoch(); taskItem.Name = asset.Name; taskItem.Description = asset.Description; taskItem.Type = (int)AssetType.Notecard; taskItem.InvType = (int)InventoryType.Notecard; taskItem.OwnerID = m_host.OwnerID; taskItem.CreatorID = m_host.OwnerID; taskItem.BasePermissions = (uint)PermissionMask.All; taskItem.CurrentPermissions = (uint)PermissionMask.All; taskItem.EveryonePermissions = 0; taskItem.NextPermissions = (uint)PermissionMask.All; taskItem.GroupID = m_host.GroupID; taskItem.GroupPermissions = 0; taskItem.Flags = 0; taskItem.PermsGranter = UUID.Zero; taskItem.PermsMask = 0; taskItem.AssetID = asset.FullID; m_host.Inventory.AddInventoryItem(taskItem, false); }
/// <summary> /// Rez a script into a prim's inventory, either ex nihilo or from an existing avatar inventory /// </summary> /// <param name="remoteClient"></param> /// <param name="itemID"> </param> /// <param name="localID"></param> public void RezScript(IClientAPI remoteClient, InventoryItemBase itemBase, UUID transactionID, uint localID) { UUID itemID = itemBase.ID; UUID copyID = UUID.Random(); if (itemID != UUID.Zero) // transferred from an avatar inventory to the prim's inventory { CachedUserInfo userInfo = CommsManager.UserService.GetUserDetails(remoteClient.AgentId); if (userInfo != null) { InventoryItemBase item = userInfo.FindItem(itemID); // Try library bool fromLibrary = false; if (null == item) { item = CommsManager.LibraryRoot.FindItem(itemID); fromLibrary = true; } if (item != null) { SceneObjectPart part = GetSceneObjectPart(localID); if (part != null) { if (!Permissions.CanEditObjectInventory(part.ParentGroup.UUID, remoteClient.AgentId)) return; part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID); part.Inventory.CreateScriptInstance(copyID, 0, ScriptStartFlags.None, DefaultScriptEngine, 0, null); part.GetProperties(remoteClient); //if the script is no copy, remove it from the avatar inventory if (!fromLibrary && ((item.CurrentPermissions & (int)PermissionMask.Copy) == 0)) { userInfo.DeleteItem(item); } } else { m_log.ErrorFormat( "[PRIM INVENTORY]: " + "Could not rez script {0} into prim local ID {1} for user {2}" + " because the prim could not be found in the region!", item.Name, localID, remoteClient.Name); } } else { m_log.ErrorFormat( "[PRIM INVENTORY]: Could not find script inventory item {0} to rez for {1}!", itemID, remoteClient.Name); } } } else // script has been rezzed directly into a prim's inventory { SceneObjectPart part = GetSceneObjectPart(itemBase.Folder); if (part == null) return; if (part.OwnerID != remoteClient.AgentId) { // Group permissions if ( (part.GroupID == UUID.Zero) || (remoteClient.GetGroupPowers(part.GroupID) == 0) || ((part.GroupMask & (uint)PermissionMask.Modify) == 0) ) return; } else { if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0) return; } if (!Permissions.CanCreateObjectInventory( itemBase.InvType, part.ParentGroup.UUID, remoteClient.AgentId)) return; AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, Encoding.UTF8.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}")); try { CommsManager.AssetCache.AddAsset(asset, AssetRequestInfo.GenericNetRequest()); } catch (AssetServerException e) { m_log.ErrorFormat("[TASK INVENTORY] Unable to rez new script. Asset write failed: {0}", e); if (remoteClient != null) remoteClient.SendAgentAlertMessage("Unable to create asset. Please try again later.", false); return; } TaskInventoryItem taskItem = new TaskInventoryItem(); taskItem.ResetIDs(itemBase.Folder); taskItem.ParentID = itemBase.Folder; taskItem.CreationDate = (uint)itemBase.CreationDate; taskItem.Name = itemBase.Name; taskItem.Description = itemBase.Description; taskItem.Type = itemBase.AssetType; taskItem.InvType = itemBase.InvType; taskItem.OwnerID = itemBase.Owner; taskItem.CreatorID = itemBase.CreatorIdAsUuid; taskItem.BasePermissions = itemBase.BasePermissions; taskItem.CurrentPermissions = itemBase.CurrentPermissions; taskItem.EveryonePermissions = itemBase.EveryOnePermissions; taskItem.GroupPermissions = itemBase.GroupPermissions; taskItem.NextPermissions = itemBase.NextPermissions; taskItem.GroupID = itemBase.GroupID; taskItem.GroupPermissions = 0; taskItem.Flags = itemBase.Flags; taskItem.PermsGranter = UUID.Zero; taskItem.PermsMask = 0; taskItem.AssetID = asset.FullID; part.Inventory.AddInventoryItem(taskItem, false, true); part.GetProperties(remoteClient); part.Inventory.CreateScriptInstance(taskItem, 0, ScriptStartFlags.None, DefaultScriptEngine, 0, null); } }
/// <summary> /// Rez a script into a prim's inventory, either ex nihilo or from an existing avatar inventory /// </summary> /// <param name="remoteClient"></param> /// <param name="itemID"> </param> /// <param name="localID"></param> public void RezScript(IClientAPI remoteClient, InventoryItemBase itemBase, UUID transactionID, uint localID) { UUID itemID = itemBase.ID; UUID copyID = UUID.Random(); if (itemID != UUID.Zero) // transferred from an avatar inventory to the prim's inventory { CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); if (userInfo != null && userInfo.RootFolder != null) { InventoryItemBase item = userInfo.RootFolder.FindItem(itemID); // Try library // XXX clumsy, possibly should be one call if (null == item) { item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); } if (item != null) { SceneObjectPart part = GetSceneObjectPart(localID); if (part != null) { if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) return; part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID); // TODO: switch to posting on_rez here when scripts // have state in inventory part.Inventory.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0); // m_log.InfoFormat("[PRIMINVENTORY]: " + // "Rezzed script {0} into prim local ID {1} for user {2}", // item.inventoryName, localID, remoteClient.Name); part.GetProperties(remoteClient); } else { m_log.ErrorFormat( "[PRIM INVENTORY]: " + "Could not rez script {0} into prim local ID {1} for user {2}" + " because the prim could not be found in the region!", item.Name, localID, remoteClient.Name); } } else { m_log.ErrorFormat( "[PRIM INVENTORY]: Could not find script inventory item {0} to rez for {1}!", itemID, remoteClient.Name); } } } else // script has been rezzed directly into a prim's inventory { SceneObjectPart part = GetSceneObjectPart(itemBase.Folder); if (part == null) return; if (part.OwnerID != remoteClient.AgentId) { // Group permissions if ((part.GroupID == UUID.Zero) || (remoteClient.GetGroupPowers(part.GroupID) == 0) || ((part.GroupMask & (uint)PermissionMask.Modify) == 0)) return; } else { if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0) return; } if (!Permissions.CanCreateObjectInventory( itemBase.InvType, part.UUID, remoteClient.AgentId)) return; AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}")); AssetService.Store(asset); TaskInventoryItem taskItem = new TaskInventoryItem(); taskItem.ResetIDs(itemBase.Folder); taskItem.ParentID = itemBase.Folder; taskItem.CreationDate = (uint)itemBase.CreationDate; taskItem.Name = itemBase.Name; taskItem.Description = itemBase.Description; taskItem.Type = itemBase.AssetType; taskItem.InvType = itemBase.InvType; taskItem.OwnerID = itemBase.Owner; taskItem.CreatorID = itemBase.CreatorIdAsUuid; taskItem.BasePermissions = itemBase.BasePermissions; taskItem.CurrentPermissions = itemBase.CurrentPermissions; taskItem.EveryonePermissions = itemBase.EveryOnePermissions; taskItem.GroupPermissions = itemBase.GroupPermissions; taskItem.NextPermissions = itemBase.NextPermissions; taskItem.GroupID = itemBase.GroupID; taskItem.GroupPermissions = 0; taskItem.Flags = itemBase.Flags; taskItem.PermsGranter = UUID.Zero; taskItem.PermsMask = 0; taskItem.AssetID = asset.FullID; part.Inventory.AddInventoryItem(taskItem, false); part.GetProperties(remoteClient); part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); } }
/// <summary> /// Rez a script into a prim's inventory, either ex nihilo or from an existing avatar inventory /// </summary> /// <param name="remoteClient"></param> /// <param name="transactionID"></param> /// <param name="localID"></param> /// <param name="itemBase"></param> protected void RezScript(IClientAPI remoteClient, InventoryItemBase itemBase, UUID transactionID, uint localID) { UUID itemID = itemBase.ID; UUID copyID = UUID.Random(); if (itemID != UUID.Zero) // transferred from an avatar inventory to the prim's inventory { InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); item = m_scene.InventoryService.GetItem(item); if (item != null) { ISceneChildEntity part = m_scene.GetSceneObjectPart (localID); if (part != null) { if (!m_scene.Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) return; part.ParentEntity.AddInventoryItem (remoteClient, localID, item, copyID); part.Inventory.CreateScriptInstance(copyID, 0, false, 0); // MainConsole.Instance.InfoFormat("[PRIMINVENTORY]: " + // "Rezzed script {0} into prim local ID {1} for user {2}", // item.inventoryName, localID, remoteClient.Name); part.GetProperties(remoteClient); } else { MainConsole.Instance.ErrorFormat( "[PRIM INVENTORY]: " + "Could not rez script {0} into prim local ID {1} for user {2}" + " because the prim could not be found in the region!", item.Name, localID, remoteClient.Name); } } else { MainConsole.Instance.ErrorFormat( "[PRIM INVENTORY]: Could not find script inventory item {0} to rez for {1}!", itemID, remoteClient.Name); } } else // script has been rezzed directly into a prim's inventory { ISceneChildEntity part = m_scene.GetSceneObjectPart (itemBase.Folder); if (part == null) return; if (!m_scene.Permissions.CanCreateObjectInventory( itemBase.InvType, part.UUID, remoteClient.AgentId)) return; AssetBase asset = new AssetBase(UUID.Random(), itemBase.Name, (AssetType)itemBase.AssetType, remoteClient.AgentId) { Description = itemBase.Description, Data = Encoding.ASCII.GetBytes(DefaultLSLScript) }; asset.ID = m_scene.AssetService.Store(asset); TaskInventoryItem taskItem = new TaskInventoryItem(); taskItem.ResetIDs(itemBase.Folder); taskItem.ParentID = itemBase.Folder; taskItem.CreationDate = (uint)itemBase.CreationDate; taskItem.Name = itemBase.Name; taskItem.Description = itemBase.Description; taskItem.Type = itemBase.AssetType; taskItem.InvType = itemBase.InvType; taskItem.OwnerID = itemBase.Owner; taskItem.CreatorID = itemBase.CreatorIdAsUuid; taskItem.CreatorData = itemBase.CreatorData; taskItem.BasePermissions = itemBase.BasePermissions; taskItem.CurrentPermissions = itemBase.CurrentPermissions; taskItem.EveryonePermissions = itemBase.EveryOnePermissions; taskItem.GroupPermissions = itemBase.GroupPermissions; taskItem.NextPermissions = itemBase.NextPermissions; taskItem.GroupID = itemBase.GroupID; taskItem.GroupPermissions = 0; taskItem.Flags = itemBase.Flags; taskItem.PermsGranter = UUID.Zero; taskItem.PermsMask = 0; taskItem.AssetID = asset.ID; taskItem.SalePrice = itemBase.SalePrice; taskItem.SaleType = itemBase.SaleType; part.Inventory.AddInventoryItem(taskItem, false); part.GetProperties(remoteClient); part.Inventory.CreateScriptInstance(taskItem, 0, false, StateSource.NewRez); } }
/// <summary> /// </summary> /// <author>Mona</author>> /// <param name="part"></param> public void addScript(SceneObjectPart part, string script) { AssetBase asset = new AssetBase(); asset.Name = "Default touch script"; asset.Description = "Default touch script"; asset.Type = 10; // 10 is the asset type for scripts. asset.FullID = UUID.Random(); asset.Data = Encoding.ASCII.GetBytes(script); m_scene.AssetService.Store(asset); TaskInventoryItem taskItem = new TaskInventoryItem(); taskItem.ResetIDs(part.UUID); taskItem.ParentID = part.UUID; taskItem.CreationDate = (uint)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; taskItem.Name = "Default touch script"; taskItem.Description = "Default touch script"; taskItem.Type = 10; taskItem.InvType = 10; taskItem.OwnerID = UUID.Zero; taskItem.CreatorID = UUID.Zero; taskItem.BasePermissions = 2147483647; //0; // Not sure, let's try zeros. taskItem.CurrentPermissions = 2147483647; //0; taskItem.EveryonePermissions = 0; taskItem.GroupPermissions = 0; taskItem.NextPermissions = 532480; //0; taskItem.GroupID = UUID.Zero; taskItem.Flags = 0; taskItem.PermsGranter = UUID.Zero; taskItem.PermsMask = 0; taskItem.AssetID = asset.FullID; part.ParentGroup.ScheduleGroupForTerseUpdate(); part.Inventory.AddInventoryItem(taskItem, false); m_scene.AddNewSceneObject(part.ParentGroup, false); part.Inventory.CreateScriptInstance(taskItem, 0, false, m_scene.DefaultScriptEngine, 0); }