Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using GTA;
- using GTA.Native;
- using System;
- using System.IO;
- using System.Windows.Forms;
- public class BetterPlayerDamageFromAccidents : Script
- {
- string ScriptName = "Better Player Damage From Accidents";
- string ScriptVer = "1.0";
- int GameTimeRef = Game.GameTime;
- int DisableControlsTime = Game.GameTime;
- bool ControlsDisabled = false;
- float OldSpeed = 0;
- int SeatbeltScore = 0;
- int NeededSeabeltScore = 100;
- public BetterPlayerDamageFromAccidents()
- {
- Function.Call(Hash._STOP_ALL_SCREEN_EFFECTS);
- Tick += OnTick;
- if (CanWeUse(Game.Player.Character.CurrentVehicle))
- {
- OldSpeed = Game.Player.Character.CurrentVehicle.Speed;
- }
- else
- {
- OldSpeed = Game.Player.Character.Velocity.Length();
- }
- }
- void OnTick(object sender, EventArgs e)
- {
- if (CanWeUse(Game.Player.Character.CurrentVehicle))
- {
- Vehicle veh = Game.Player.Character.CurrentVehicle;
- if (Game.Player.Character.CanFlyThroughWindscreen && !veh.Model.IsBike && !veh.Model.IsBicycle)
- {
- if (veh.IsStopped && SeatbeltScore < NeededSeabeltScore) SeatbeltScore++;
- if (SeatbeltScore == NeededSeabeltScore)
- {
- Game.Player.Character.CanFlyThroughWindscreen = false;
- DisplayHelpTextThisFrame("~g~Seatbelt on.");
- }
- }
- }
- else
- {
- if (SeatbeltScore != 0) SeatbeltScore = 0;
- if (!Game.Player.Character.CanFlyThroughWindscreen) Game.Player.Character.CanFlyThroughWindscreen=true;
- }
- if (ControlsDisabled)
- {
- Game.DisableAllControlsThisFrame(2);
- }
- if (Game.GameTime > DisableControlsTime)
- {
- ControlsDisabled = false;
- Function.Call(Hash._TRANSITION_FROM_BLURRED, 500f);
- }
- if (Game.GameTime > GameTimeRef + 100)
- {
- if (CanWeUse(Game.Player.Character.CurrentVehicle))
- {
- Vehicle veh = Game.Player.Character.CurrentVehicle;
- float SpeedDifference = Math.Abs(Game.Player.Character.CurrentVehicle.Speed - OldSpeed);
- int Treshold = 3;
- if (veh.Model.IsBike || veh.Model.IsBicycle) Treshold = 5;
- if (Math.Abs(SpeedDifference) > Treshold)
- {
- if (Game.Player.Character.GetConfigFlag(32))
- {
- Function.Call(Hash._START_SCREEN_EFFECT, "SwitchShortTrevorIn", 500, false);
- int damage = (int)SpeedDifference;
- if (veh.IsUpsideDown)
- {
- damage = damage * 2;
- Game.Player.Character.ApplyDamage((int)Math.Abs(damage));
- }
- else
- {
- Game.Player.Character.ApplyDamage((int)Math.Abs(damage));
- }
- if (damage > 10 && !Game.Player.Character.IsWearingHelmet)
- {
- ControlsDisabled = true;
- DisableControlsTime = Game.GameTime + ((damage * 1000) / 10);
- Function.Call(Hash._TRANSITION_TO_BLURRED, 1);
- }
- }
- }
- OldSpeed = Game.Player.Character.CurrentVehicle.Speed;
- }
- else if (OldSpeed > 0) OldSpeed = 0;
- GameTimeRef = Game.GameTime;
- }
- }
- /// TOOLS ///
- 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