za0 3 Posted July 17, 2023 So I put this code in the initialization field of a trigger: private _posATL = player modelToWorld [0,10,0]; private _ps1 = "#particlesource" createVehicleLocal _posATL; _ps1 setParticleParams [ "\A3\Data_F\ParticleEffects\Pstone\Pstone", "", "SpaceObject", 1, 10, [0, 0, 30], [0, 0, -2], 1, 10, 1, 0.2, [2, 2], [[1, 1, 1 ,1]], [0, 1], 1, 0, "", "", _ps1]; _ps1 setParticleRandom [0, [10, 10, 0], [0.25, 0.25, 0], 0, 1.5, [0, 0, 0, 0], 0, 0]; _ps1 setDropInterval 0.04; And the particle effect works. I got this code from the BI website at this link https://community.bistudio.com/wiki/Particles_Tutorial that talks about particles: More specifically, it's rock shower code. But here's the problem: I can't delete the effect, either the rock shower or any other effect. When the trigger activates, the effect starts, but I don't know how to stop it. I already tried deleting the trigger, and using the example that says on the site mentioned above deleteVehicle _ps1; But nothing.. Any ideas? Thanks in advance! Share this post Link to post Share on other sites
Harzach 2517 Posted July 17, 2023 42 minutes ago, za0 said: But nothing It works fine, you just need to execute it in the same scope as the particles were created: 0 = [] spawn { private _posATL = player modelToWorld [0,10,0]; private _ps1 = "#particlesource" createVehicleLocal _posATL; _ps1 setParticleParams [ "\A3\Data_F\ParticleEffects\Pstone\Pstone", "", "SpaceObject", 1, 10, [0, 0, 30], [0, 0, -2], 1, 10, 1, 0.2, [2, 2], [[1, 1, 1 ,1]], [0, 1], 1, 0, "", "", _ps1]; _ps1 setParticleRandom [0, [10, 10, 0], [0.25, 0.25, 0], 0, 1.5, [0, 0, 0, 0], 0, 0]; _ps1 setDropInterval 0.04; sleep 15; deleteVehicle _ps1; }; Or use a global variable. Share this post Link to post Share on other sites
za0 3 Posted July 17, 2023 Hey! It worked! Thank you Harzach! I don't understand much about programming but I'm learning little by little. So that initial code that I had tested was in local scope and what you did was pass it to global using 0 = [] spawn { }; ? Share this post Link to post Share on other sites
Harzach 2517 Posted July 17, 2023 No, I just spawned the code so I could use the sleep. Local variables only exist where they are declared. For example, inside the script or function where they are declared. Global variables exist "everywhere" on the computer where they are declared. If I run this in the debug console: private _posATL = player modelToWorld [0,10,0]; private _ps1 = "#particlesource" createVehicleLocal _posATL; _ps1 setParticleParams [ "\A3\Data_F\ParticleEffects\Pstone\Pstone", "", "SpaceObject", 1, 10, [0, 0, 30], [0, 0, -2], 1, 10, 1, 0.2, [2, 2], [[1, 1, 1 ,1]], [0, 1], 1, 0, "", "", _ps1]; _ps1 setParticleRandom [0, [10, 10, 0], [0.25, 0.25, 0], 0, 1.5, [0, 0, 0, 0], 0, 0]; _ps1 setDropInterval 0.04; ...it works fine. However, I can't go back and reference _ps1: deleteVehicle _ps1; ...because the previous code was compiled and called - it exists in its own scope now. By spawning the code, I can introduce a sleep (or some other structure like waitUntil), then delete the particles. Everything exists within the scope of the spawned code block. As for global variables, all you need to do is remove the underscore - _ps1 becomes ps1. Now, you can call your code: private _posATL = player modelToWorld [0,10,0]; private ps1 = "#particlesource" createVehicleLocal _posATL; ps1 setParticleParams [ "\A3\Data_F\ParticleEffects\Pstone\Pstone", "", "SpaceObject", 1, 10, [0, 0, 30], [0, 0, -2], 1, 10, 1, 0.2, [2, 2], [[1, 1, 1 ,1]], [0, 1], 1, 0, "", "", ps1]; ps1 setParticleRandom [0, [10, 10, 0], [0.25, 0.25, 0], 0, 1.5, [0, 0, 0, 0], 0, 0]; ps1 setDropInterval 0.04; ...and the global ps1 remains available to the machine where it was created, allowing you to delete the particles at your leisure: deleteVehicle ps1; Kind of a clunky explanation as I'm no expert myself, but I hope it helps. Check out the first few Biki links in my signature. Share this post Link to post Share on other sites