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.Windows.Forms;
- using NativeUI;
- using System.Collections.Generic;
- using System.IO;
- public class SuperHot : Script
- {
- string ScreenEffect = "RaceTurbo";
- string ScriptName = "SUPERHOT Abilities";
- string ScriptVer = "v1.2";
- // List<WeaponHash> SingleShotWeapons = new List<WeaponHash>();
- List<string> EmptyClipMessages = new List<string> { "YOU'RE OUT","MAGAZINE EMPTY", "NO AMMO"};
- List<string> CreepyMessages = new List<string> { "YOU'RE NOT IN CONTROL", "SUPERHOT.EXE", "DANCE FOR US","WE OWN YOU","WE'RE WATCHING YOU","MIND IS SOFTWARE","BODY IS DISPOSABLE"};
- bool SuperHotEnabled =false;
- bool CanNotifyOfEmptyClip = true;
- bool CanHotSwitch = true;
- int ticks = 0;
- int HotSwitchCoolDown = Game.GameTime;
- //SETTINGS
- float minTimeScale = 0.1f;
- float maxTimeScale =1.0f;
- int HotSwitchCooldownTime = 5;
- int SuperHotNotification = 0;
- public SuperHot()
- {
- Tick += OnTick;
- LoadSettings();
- }
- void HandleSuperHotToggle()
- {
- if (Game.CurrentInputMode == InputMode.MouseAndKeyboard)
- {
- if (Game.Player.IsAiming && Game.IsKeyPressed(Keys.ShiftKey) && Game.IsControlJustPressed(2, GTA.Control.Context))
- {
- if((SuperHotEnabled && !CanWeUse(Game.Player.GetTargetedEntity()) || !SuperHotEnabled))
- {
- SuperHotEnabled = !SuperHotEnabled;
- if (SuperHotEnabled)
- {
- LoadSettings();
- Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "BASE_JUMP_PASSED", "HUD_AWARDS");
- BigMessageThread.MessageInstance.ShowColoredShard("SUPER HOT", "", HudColor.HUD_COLOUR_BLACK, HudColor.HUD_COLOUR_BLUE, 300);
- ticks = 3;
- SuperHotNotification = 1;
- }
- if (!SuperHotEnabled)
- {
- Game.TimeScale = 1;
- Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "BASE_JUMP_PASSED", "HUD_AWARDS");
- BigMessageThread.MessageInstance.ShowColoredShard(CreepyMessages[RandomInt(0, CreepyMessages.Count - 1)], "", HudColor.HUD_COLOUR_BLACK, HudColor.HUD_COLOUR_RED, 300);
- ticks = 1;
- if (ScreenEffect.Length > 0) Function.Call(Hash._STOP_SCREEN_EFFECT, ScreenEffect);
- }
- }
- }
- }
- else
- {
- if (Game.Player.IsAiming && Game.IsControlJustPressed(2, GTA.Control.Context))
- {
- SuperHotEnabled = !SuperHotEnabled;
- if (SuperHotEnabled)
- {
- Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "BASE_JUMP_PASSED", "HUD_AWARDS");
- BigMessageThread.MessageInstance.ShowColoredShard("SUPER HOT", "", HudColor.HUD_COLOUR_BLACK, HudColor.HUD_COLOUR_BLUE, 300);
- ticks = 3;
- SuperHotNotification = 1;
- }
- if (!SuperHotEnabled)
- {
- Game.TimeScale = 1;
- Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "BASE_JUMP_PASSED", "HUD_AWARDS");
- BigMessageThread.MessageInstance.ShowColoredShard(CreepyMessages[RandomInt(0, CreepyMessages.Count - 1)], "", HudColor.HUD_COLOUR_BLACK, HudColor.HUD_COLOUR_RED, 300);
- ticks = 1;
- }
- }
- }
- }
- void OnTick(object sender, EventArgs e)
- {
- HandleSuperHotToggle();
- if (!CanHotSwitch && Game.GameTime > HotSwitchCoolDown)
- {
- CanHotSwitch = true;
- Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "BASE_JUMP_PASSED", "HUD_AWARDS");
- BigMessageThread.MessageInstance.ShowColoredShard("HOTSWITCH READY", "", HudColor.HUD_COLOUR_BLACK, HudColor.HUD_COLOUR_BLUE, 300);
- ticks = 1;
- }
- if (ticks > 0) ticks++;
- if (SuperHotNotification > 3) SuperHotNotification = 0;
- if (SuperHotEnabled)
- {
- if (!Game.Player.IsAlive) SuperHotEnabled = false;
- HandleSuperHot();
- HandleClip();
- if(ticks > 10)
- {
- BigMessageThread.MessageInstance.ShowSimpleShard("", "", 0);
- ticks = 0;
- if (SuperHotNotification > 0)
- {
- Wait(50);
- SuperHotNotification++;
- Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "BASE_JUMP_PASSED", "HUD_AWARDS");
- BigMessageThread.MessageInstance.ShowColoredShard("SUPER HOT", "",HudColor.HUD_COLOUR_BLACK, HudColor.HUD_COLOUR_BLUE, 300);
- ticks = 3;
- }
- }
- }
- }
- int RandomInt(int min, int max)
- {
- max++;
- return Function.Call<int>(GTA.Native.Hash.GET_RANDOM_INT_IN_RANGE, min, max);
- }
- void HandleClip()
- {
- if (CanNotifyOfEmptyClip == true && Game.Player.IsAlive && Game.Player.Character.Weapons.Current.DefaultClipSize > 1 && Game.Player.Character.Weapons.Current.AmmoInClip == 0 && (Game.Player.Character.IsShooting))
- {
- Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "BASE_JUMP_PASSED", "HUD_AWARDS");
- BigMessageThread.MessageInstance.ShowColoredShard(EmptyClipMessages[RandomInt(0,EmptyClipMessages.Count-1)], "", HudColor.HUD_COLOUR_BLACK, HudColor.HUD_COLOUR_BLUE, 300);
- ticks = 1;
- CanNotifyOfEmptyClip = false;
- }
- if (CanNotifyOfEmptyClip == false && Game.Player.Character.Weapons.Current.AmmoInClip != 0) CanNotifyOfEmptyClip = true;
- }
- bool CanWeUse(Entity entity)
- {
- return entity != null && entity.Exists();
- }
- void LoadSettings()
- {
- if (File.Exists(@"scripts\\SUPERHOT.ini"))
- {
- ScriptSettings config = ScriptSettings.Load(@"scripts\SUPERHOT.ini");
- minTimeScale = config.GetValue<float>("GENERAL_SETTINGS", "minTimeScale", 0.03f);
- maxTimeScale = config.GetValue<float>("GENERAL_SETTINGS", "maxTimeScale", 1.0f);
- HotSwitchCooldownTime = (int)config.GetValue<float>("GENERAL_SETTINGS", "HotSwitchCooldownTime", 5f) *1000;
- ScreenEffect = config.GetValue<string>("GENERAL_SETTINGS", "ScreenEffect", "");
- }
- else
- {
- WarnPlayer(ScriptName+" "+ScriptVer, "CONFIG NOT FOUND", "SUPERHOT.ini not found. Loading default values.");
- }
- }
- 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);
- }
- void HandleSuperHot()
- {
- if(ScreenEffect.Length>0) Function.Call(Hash._START_SCREEN_EFFECT, ScreenEffect, 0, false);
- if (Game.Player.IsAiming && Game.IsControlJustPressed(2,GTA.Control.Context)&& CanWeUse(Game.Player.GetTargetedEntity()))
- {
- if(CanHotSwitch)
- {
- if (Function.Call<bool>(Hash.IS_ENTITY_A_PED, Game.Player.GetTargetedEntity()))
- {
- Ped victim = Game.Player.GetTargetedEntity() as Ped;
- if (victim.IsSittingInVehicle())
- {
- Vehicle playerveh = Game.Player.Character.CurrentVehicle;
- Vehicle veh = victim.CurrentVehicle;
- Vector3 pos = victim.Position - victim.UpVector;
- float heading = victim.Heading;
- victim.Position = Game.Player.Character.Position;
- victim.Heading = Game.Player.Character.Heading;
- Game.Player.Character.SetIntoVehicle(veh, VehicleSeat.Driver);
- if (CanWeUse(playerveh))
- {
- victim.SetIntoVehicle(playerveh, VehicleSeat.Driver);
- playerveh.SoundHorn(0);
- }
- }
- else
- {
- Vector3 pos = victim.Position - victim.UpVector;
- float heading = victim.Heading;
- victim.Position = Game.Player.Character.Position;
- victim.Heading = Game.Player.Character.Heading;
- Game.Player.Character.Position = pos;
- Game.Player.Character.Heading = heading;
- if (victim.IsDead)
- {
- victim.Position = victim.Position - (new Vector3(0, 0, victim.HeightAboveGround));
- }
- }
- HotSwitchCoolDown = Game.GameTime + HotSwitchCooldownTime;
- Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "BASE_JUMP_PASSED", "HUD_AWARDS");
- BigMessageThread.MessageInstance.ShowColoredShard("NEW BODY", "", HudColor.HUD_COLOUR_BLACK, HudColor.HUD_COLOUR_BLUE, 300);
- ticks = 1;
- CanHotSwitch = false;
- }
- }
- else
- {
- Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "BASE_JUMP_PASSED", "HUD_AWARDS");
- BigMessageThread.MessageInstance.ShowColoredShard("NOT READY", "", HudColor.HUD_COLOUR_BLACK, HudColor.HUD_COLOUR_BLUE, 300);
- ticks = 1;
- }
- }
- if (!Game.Player.Character.IsOnFoot)
- {
- Game.TimeScale = 1f;
- }
- else
- {
- float speed = Game.Player.Character.Velocity.Length();
- float mouse = Math.Abs(((Function.Call<float>(Hash.GET_CONTROL_NORMAL, 0, (int)GTA.Control.LookLeftRight) + Function.Call<float>(Hash.GET_CONTROL_NORMAL, 0, (int)GTA.Control.LookUpDown)) / 2) * 5);
- float rot = Math.Max(Function.Call<Vector3>(Hash.GET_ENTITY_ROTATION_VELOCITY, Game.Player.Character).Z, mouse);
- float scale = Math.Max(rot, speed);
- scale = scale / 4;
- if (Game.Player.Character.IsRagdoll || Game.Player.Character.IsGettingUp) Game.TimeScale = 1;
- else
- {
- if (scale < minTimeScale)
- {
- Game.TimeScale = minTimeScale;
- }
- if (scale >= minTimeScale)
- {
- Game.TimeScale = scale;
- }
- if (scale < 0.3f && Game.IsControlPressed(2, GTA.Control.Attack) && Game.Player.Character.Weapons.Current.AmmoInClip != 0)
- {
- Game.TimeScale = 0.3f;
- }
- if (scale < 0.2f && IsPlayerTryingToMove()) Game.TimeScale = 0.2f;
- if (scale > maxTimeScale)
- {
- Game.TimeScale = maxTimeScale;
- }
- }
- // UI.ShowSubtitle("~r~" + (Math.Round(scale,2)).ToString());
- }
- }
- bool IsPlayerTryingToMove()
- {
- if (Game.IsControlPressed(2, GTA.Control.MoveDownOnly) || Game.IsControlPressed(2, GTA.Control.MoveUpOnly) || Game.IsControlPressed(2, GTA.Control.MoveLeftOnly) || Game.IsControlPressed(2, GTA.Control.MoveRightOnly)) return true;
- return false;
- }
- protected override void Dispose(bool dispose)
- {
- Game.TimeScale = 1;
- base.Dispose(dispose);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement