Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using GTA;
- using GTA.Native;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Windows.Forms;
- public class AutoTurbo : Script
- {
- string ScriptName = "AutoTurbo";
- string ScriptVer = "1.0";
- int GametimeRef = 0;
- bool Debug = false;
- bool AllCars = false;
- public AutoTurbo()
- {
- Tick += OnTick;
- LoadSettings(false);
- }
- void OnTick(object sender, EventArgs e)
- {
- if(WasCheatStringJustEntered("reload autoturbo"))
- {
- Models.Clear();
- LoadSettings(true);
- }
- if (GametimeRef < Game.GameTime)
- {
- GametimeRef = Game.GameTime + 1000;
- if (AllCars)
- {
- foreach(Vehicle v in World.GetAllVehicles())
- {
- if (Models.Contains(v.Model))
- {
- if (!v.IsToggleModOn(VehicleToggleMod.Turbo))
- {
- v.ToggleMod(VehicleToggleMod.Turbo, true);
- if (Debug) UI.Notify("~b~[AutoTurbo]" + v.FriendlyName + " Turbo has been enabled");
- }
- }
- }
- }
- else
- {
- if (CanWeUse(Game.Player.Character.CurrentVehicle))
- {
- Vehicle v = Game.Player.Character.CurrentVehicle;
- if (Models.Contains(v.Model))
- {
- if (!v.IsToggleModOn(VehicleToggleMod.Turbo))
- {
- v.ToggleMod(VehicleToggleMod.Turbo, true);
- if (Debug) UI.Notify("~b~[AutoTurbo]" + v.FriendlyName + " Turbo has been enabled");
- }
- }
- }
- }
- }
- }
- public static bool WasCheatStringJustEntered(string cheat)
- {
- return Function.Call<bool>(Hash._0x557E43C447E700A8, Game.GenerateHash(cheat));
- }
- protected override void Dispose(bool dispose)
- {
- base.Dispose(dispose);
- }
- List<Model> Models = new List<Model>();
- /// TOOLS ///
- void LoadSettings(bool debug)
- {
- if (File.Exists(@"scripts\\AutoTurbo.ini"))
- {
- if(debug) UI.Notify("Loading AutoTurbo models:");
- ScriptSettings config = ScriptSettings.Load(@"scripts\SCRIPTNAME.ini");
- foreach (string value in config.GetAllValues("GENERAL_SETTINGS", "model"))
- {
- Models.Add(value);
- if (debug) UI.Notify(value+ " loaded");
- }
- AllCars = config.GetValue<bool>("GENERAL_SETTINGS", "AllCars", false);
- Debug = config.GetValue<bool>("GENERAL_SETTINGS", "Debug", false);
- }
- else
- {
- WarnPlayer(ScriptName + " " + ScriptVer, "SCRIPT RESET", "~r~AutoTurbo can't find AutoTurbo.ini. All settings default.");
- }
- }
- 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