Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using GTA;
- using GTA.Math;
- using GTA.Native;
- using System;
- using System.IO;
- using System.Windows.Forms;
- public class ScriptTest : Script
- {
- string ScriptName = "PlaneAirCondensation";
- string ScriptVer = "1.0";
- public ScriptTest()
- {
- Tick += OnTick;
- KeyDown += OnKeyDown;
- KeyUp += OnKeyUp;
- LoadSettings(false);
- }
- public static Vector3 LerpByDistance(Vector3 A, Vector3 B, float x)
- {
- Vector3 P = x * Vector3.Normalize(B - A) + A;
- return P;
- }
- string core = "scr_recartheft";
- string ptfx = "scr_wheel_burnout";
- float scale = 0.05f;
- float separation = 0.2f;
- float speed = 300;
- void OnTick(object sender, EventArgs e)
- {
- if(WasCheatStringJustEntered("pacupdate"))
- {
- LoadSettings(true);
- return;
- }
- Vehicle v = Game.Player.Character.CurrentVehicle;
- if (CanWeUse(v) && v.Model.IsPlane&&v.HeightAboveGround>50)
- {
- // Function.Call(Hash.REQUEST_NAMED_PTFX_ASSET, core);
- //Function.Call(Hash._SET_PTFX_ASSET_NEXT_CALL, core);
- // Function.Call<int>(Hash.START_PARTICLE_FX_NON_LOOPED_ON_ENTITY, ptfx, v,0,0,0, 0, 0, 0, 1f, 0, 1, 0);
- // DisplayHelpTextThisFrame((Function.Call<Vector3>(Hash.GET_ENTITY_ROTATION_VELOCITY, v, true).Y).ToString());
- if (Math.Abs(Function.Call<Vector3>(Hash.GET_ENTITY_ROTATION_VELOCITY, v, true).Y) > 0.5f && v.Speed * 3.6f > speed)//Math.Abs(Function.Call<float>(Hash.GET_ENTITY_ROTATION_VELOCITY, v))>0.2f
- {
- if (Function.Call<bool>(Hash.HAS_NAMED_PTFX_ASSET_LOADED, core))
- {
- Vector3 orientation = v.Rotation;
- string left = "siren2";
- string right = "siren1";
- if (!v.HasBone("siren2"))
- {
- left = "wingtip_l";
- right = "wingtip_r";
- }
- Vector3 coord = Vector3.Zero;
- if (v.HasBone(right))
- {
- coord = v.GetBoneCoord(v.GetBoneIndex(right));
- }
- else
- {
- coord = v.Position + (v.RightVector * v.Model.GetDimensions().X);
- }
- float i = 0.5f;
- while (i < v.Model.GetDimensions().Y / 3) //
- {
- i += separation;
- Vector3 localcoord = LerpByDistance(v.Position + (v.ForwardVector * 0), v.GetBoneCoord(v.GetBoneIndex(right)), i);
- localcoord = Function.Call<Vector3>(Hash.GET_OFFSET_FROM_ENTITY_GIVEN_WORLD_COORDS, v, localcoord.X, localcoord.Y, localcoord.Z);
- Function.Call(Hash._SET_PTFX_ASSET_NEXT_CALL, core);
- Function.Call<int>(Hash.START_PARTICLE_FX_NON_LOOPED_ON_ENTITY, ptfx, v, localcoord.X, localcoord.Y, localcoord.Z, orientation.X, orientation.Y, orientation.Z, scale, 1, 1, 1);
- }
- i = 0.5f;
- if (v.HasBone(left))
- {
- coord = v.GetBoneCoord(v.GetBoneIndex(left));
- }
- else
- {
- coord = v.Position - (v.RightVector * v.Model.GetDimensions().X);
- }
- while (i < v.Model.GetDimensions().Y / 3) //
- {
- i += separation;
- Vector3 localcoord = LerpByDistance(v.Position + (v.ForwardVector * 0), v.GetBoneCoord(v.GetBoneIndex(left)), i);
- localcoord = Function.Call<Vector3>(Hash.GET_OFFSET_FROM_ENTITY_GIVEN_WORLD_COORDS, v, localcoord.X, localcoord.Y, localcoord.Z);
- Function.Call(Hash._SET_PTFX_ASSET_NEXT_CALL, core);
- Function.Call<int>(Hash.START_PARTICLE_FX_NON_LOOPED_ON_ENTITY, ptfx, v, localcoord.X, localcoord.Y, localcoord.Z, orientation.X, orientation.Y, orientation.Z, scale, 1, 1, 1);
- }
- //scr_meth_pipe_smoke scr_familyscenem
- /*
- coord = Function.Call<Vector3>(Hash.GET_OFFSET_FROM_ENTITY_GIVEN_WORLD_COORDS, v, coord.X, coord.Y, coord.Z);
- Function.Call(Hash._SET_PTFX_ASSET_NEXT_CALL, "scr_familyscenem");
- Function.Call<int>(Hash.START_PARTICLE_FX_NON_LOOPED_ON_ENTITY, "scr_meth_pipe_smoke", v, coord.X, coord.Y, coord.Z, 0, 0, 0, 3f, 0, 1, 0);
- */
- /*
- coord = v.GetBoneCoord(v.GetBoneIndex("siren1"));
- i = 0;
- while (i<10) //
- {
- i++;
- coord= LerpByDistance(coord, v.Position, 1f);
- Vector3 localcoord = Function.Call<Vector3>(Hash.GET_OFFSET_FROM_ENTITY_GIVEN_WORLD_COORDS, v, coord.X, coord.Y, coord.Z);
- Function.Call(Hash._SET_PTFX_ASSET_NEXT_CALL, "scr_familyscenem");
- Function.Call<int>(Hash.START_PARTICLE_FX_NON_LOOPED_ON_ENTITY, "scr_meth_pipe_smoke", v, localcoord.X, localcoord.Y, localcoord.Z, 0, 0, 0, 2f, 0, 1, 0);
- }
- */
- }
- else Function.Call(Hash.REQUEST_NAMED_PTFX_ASSET, core);
- }
- }
- }
- void OnKeyDown(object sender, KeyEventArgs e)
- {
- }
- void OnKeyUp(object sender, KeyEventArgs e)
- {
- }
- protected override void Dispose(bool dispose)
- {
- Function.Call(Hash._REMOVE_NAMED_PTFX_ASSET, core);
- base.Dispose(dispose);
- }
- public static bool WasCheatStringJustEntered(string cheat)
- {
- return Function.Call<bool>(Hash._0x557E43C447E700A8, Game.GenerateHash(cheat));
- }
- /// TOOLS ///
- void LoadSettings(bool notify)
- {
- if (File.Exists(@"scripts\\PlaneAirCondensation.ini"))
- {
- ScriptSettings config = ScriptSettings.Load(@"scripts\PlaneAirCondensation.ini");
- core = config.GetValue<string>("SETTINGS", "PTFXAsset", "scr_recartheft");
- ptfx = config.GetValue<string>("SETTINGS", "FX", "scr_wheel_burnout");
- scale = config.GetValue<float>("SETTINGS", "Scale", 0.05f);
- separation = config.GetValue<float>("SETTINGS", "Separation", 0.2f);
- speed = config.GetValue<float>("SETTINGS", "MinSpeed", 300);
- if (notify) UI.Notify("~g~PTFXAsset: ~b~" + core);
- if (notify) UI.Notify("~g~FX: ~b~" + ptfx);
- if (notify) UI.Notify("~g~Scale: ~b~" + scale);
- if (notify) UI.Notify("~g~Separation: ~b~" + separation);
- if (notify) UI.Notify("~g~MinSpeed: ~b~" + speed);
- }
- else
- {
- if (notify) WarnPlayer(ScriptName + " " + ScriptVer, "FILE NOT FOUND", "~r~PlaneAirCondensation.ini doesn't exist.");
- }
- }
- void WarnPlayer(string script_name, string title, string message)
- {
- Function.Call(Hash._SET_NOTIFICATION_TEXT_ENTRY, "STRING");
- Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, message);
- Function.Call(Hash._SET_NOTIFICATION_MESSAGE, "CHAR_SOCIAL_CLUB", "CHAR_SOCIAL_CLUB", true, 0, title, "~b~" + script_name);
- }
- bool CanWeUse(Entity entity)
- {
- return entity != null && entity.Exists();
- }
- void DisplayHelpTextThisFrame(string text)
- {
- Function.Call(Hash._SET_TEXT_COMPONENT_FORMAT, "STRING");
- Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, text);
- Function.Call(Hash._DISPLAY_HELP_TEXT_FROM_STRING_LABEL, 0, false, true, -1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement