Trigger a partical effect with hotkey?
-
I've seen this done with trainers, is it possible to activate one with a hotkey?
-
using GTA; using GTA.Math; using GTA.Native; using System; using System.Windows.Forms; class MyMod : Script { string assetName = "put_asset_name_here", effectName = "put_effect_name_here"; int ptfxHandle = -1; public MyMod() { KeyDown += MyMod_KeyDown; } public void MyMod_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.K) { //stop ptfx if still exists if (Function.Call<bool>(Hash.DOES_PARTICLE_FX_LOOPED_EXIST, ptfxHandle)) { Function.Call(Hash.REMOVE_PARTICLE_FX, ptfxHandle, false); } ptfxHandle = -1; //request ptfx DateTime endtime = DateTime.UtcNow + new TimeSpan(0, 0, 0, 0, 1000); //1000 milliseconds from now while (DateTime.UtcNow < endtime && !Function.Call<bool>(Hash.HAS_NAMED_PTFX_ASSET_LOADED, assetName)) { Function.Call(Hash.REQUEST_NAMED_PTFX_ASSET, assetName); Yield(); } if (Function.Call<bool>(Hash.HAS_NAMED_PTFX_ASSET_LOADED, assetName)) { Function.Call(Hash._USE_PARTICLE_FX_ASSET_NEXT_CALL, assetName); //edit these to your liking Vector3 location = Game.Player.Character.Position; Vector3 rotation = Vector3.Zero; float scale = 8f; int ptfxHandle = Function.Call<int>(Hash.START_PARTICLE_FX_LOOPED_AT_COORD, effectName, location.X, location.Y, location.Z, rotation.X, rotation.Y, rotation.Z, scale, false, false, false, false); if (!Function.Call<bool>(Hash.DOES_PARTICLE_FX_LOOPED_EXIST, Handle)) ptfxHandle = -1; } } } }
There is also this class from SHVDN3 that could be helpful: https://github.com/crosire/scripthookvdotnet/blob/d695fd74cef2286c72b57c640aa4640ad814df5b/source/scripting/World/ParticleEffects.cs