Scripting Moderators ds1-e Posted February 1, 2019 Scripting Moderators Share Posted February 1, 2019 Hey. I have question, if i attach sound to player i need destroy it? By using attachElements or attachElementToBone(aSound, source, 3, 0.19, -0.31, -0.1, 0, 270, -90) Thanks for help anyway. Link to comment
Peti Posted February 1, 2019 Share Posted February 1, 2019 You want to destroy an attached sound? Link to comment
Moderators IIYAMA Posted February 1, 2019 Moderators Share Posted February 1, 2019 You can also make the sound a child of a player. setElementParent(sound, player) This will auto destroy the sound when the player leaves the server. Link to comment
Scripting Moderators ds1-e Posted February 1, 2019 Author Scripting Moderators Share Posted February 1, 2019 (edited) 1 hour ago, Peti said: You want to destroy an attached sound? No, i want to know if i need to destroy sound. Attached sound have normal behaviour like sound which isn't attached to player? (loop = false) Edited February 1, 2019 by majqq Link to comment
Moderators IIYAMA Posted February 1, 2019 Moderators Share Posted February 1, 2019 1 hour ago, majqq said: No, i want to know if i need to destroy sound. Attached sound have normal behaviour like sound which isn't attached to player? (loop = false) If it is not looped or streamed, then it will destroy itself when it ends. 1 1 Link to comment
Discord Moderators Pirulax Posted February 2, 2019 Discord Moderators Share Posted February 2, 2019 On 01/02/2019 at 17:23, IIYAMA said: You can also make the sound a child of a player. setElementParent(sound, player) This will auto destroy the sound when the player leaves the server. You sure about that? On the wiki it says: Quote This function does not change when an element will be destroyed - Elements are always destroyed when the resource that created them is stopped. 1 Link to comment
Moderators IIYAMA Posted February 3, 2019 Moderators Share Posted February 3, 2019 39 minutes ago, Pirulax said: You sure about that? On the wiki it says: Quote This function does not change when an element will be destroyed - Elements are always destroyed when the resource that created them is stopped. That is about this: 1. Resource 1 <resourceRoot></resourceRoot> Resource 2 <resourceRoot></resourceRoot> ------------------------------ 2. Resource 1 example = createElement("example", "example") <resourceRoot> <example id="example"></example> </resourceRoot> Resource 2 <resourceRoot></resourceRoot> ------------------------------ 3. Resource 1 <resourceRoot> <example id="example"></example> </resourceRoot> example = getElementByID("example") setElementParent(example, resourceRoot) New structure: <resourceRoot></resourceRoot> Resource 2 <resourceRoot> <example id="example"></example> </resourceRoot> ------------------------------ It looks now as if the element <example> has been transferred to another resource. But it didn't. It is still part of resource 1. If you stop resource 1, then the <example> element will still be destroyed. < that comment it about his. And the funny thing is, that <example> will ALSO be destroyed when you stop resource 2 That poor example does not stand a chance! And this comment for some reason doesn't make sense, because I have never seen this happen. Quote Note: When an element is destroyed, its parent becomes the new parent of its children. Link to comment
Moderators IIYAMA Posted February 3, 2019 Moderators Share Posted February 3, 2019 @majqq@Pirulax I am terrible sorry. It seems like my information is partly incorrect. I tested it: It seems that it only will destroy children when you manually destroy an element. (It will only destroy it's children with destroyElement + propagation is enabled) Quote And the funny thing is, that <example> will ALSO be destroyed when you stop resource 2 And changing the parent to player doesn't work. Quote setElementParent(sound, player) Information that is still correct: Sound elements do destroy them self after ending. 1 Link to comment
Scripting Moderators ds1-e Posted February 3, 2019 Author Scripting Moderators Share Posted February 3, 2019 6 hours ago, IIYAMA said: @majqq@Pirulax I am terrible sorry. It seems like my information is partly incorrect. I tested it: It seems that it only will destroy children when you manually destroy an element. (It will only destroy it's children with destroyElement + propagation is enabled) And changing the parent to player doesn't work. Information that is still correct: Sound elements do destroy them self after ending. What about your solution for this? Because i didn't test it/create it yet. Everything should be okay? 1 Link to comment
Moderators IIYAMA Posted February 3, 2019 Moderators Share Posted February 3, 2019 13 minutes ago, majqq said: What about your solution for this? Because i didn't test it/create it yet. Everything should be okay? That should be fine, as long as the sound stays the child and not the parent. 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now