Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* SCREAMING INJURED PEDS *
- * a GTA V script made by EnforcerZhukov, *
- * updated (unofficially) by Xire using ChatGPT *
- * https://github.com/David-Lor/ScreamingInjuredPeds */
- using GTA;
- using GTA.Native;
- using GTA.Math;
- using System;
- using System.Collections.Generic;
- public class ScreamingInjuredPeds : Script
- {
- // Settings
- private bool setBlipsOnInjuredPeds = false;
- private int cooldown = 5; //cooldown timer
- private List<Ped> injured = new List<Ped>();
- private List<Ped> injuredRmv = new List<Ped>();
- private List<DateTime> execTime = new List<DateTime>();
- private Random r = new Random();
- private DateTime firstDT;
- private TimeSpan dff;
- private Dictionary<Ped, Blip> blipDict = new Dictionary<Ped, Blip>();
- public ScreamingInjuredPeds()
- {
- Tick += OnTick;
- Interval = 100;
- firstDT = new DateTime(1999, 1, 1);
- }
- void OnTick(object sender, EventArgs e)
- {
- DateTime now = DateTime.UtcNow;
- foreach (Ped p in World.GetAllPeds())
- {
- if (!injured.Contains(p)
- && Function.Call<bool>(Hash.IS_PED_HURT, p)
- && p.IsAlive && p.IsHuman)
- {
- injured.Add(p);
- execTime.Add(firstDT);
- }
- }
- for (int i = injured.Count - 1; i >= 0; i--)
- {
- Ped p = injured[i];
- DateTime prev = execTime[i];
- dff = now - prev;
- if (p.IsDead)
- {
- injuredRmv.Add(p);
- continue;
- }
- bool firstTime = (prev.Year == 1999);
- if (firstTime || dff.TotalSeconds >= cooldown)
- {
- string facialLib = p.Gender == Gender.Female
- ? "facials@gen_female@base"
- : "facials@gen_male@base";
- int style = r.Next(0, 3);
- if (style == 0)
- Function.Call(Hash.PLAY_PAIN, p, 19, 1, 0f);
- else if (style == 1)
- Function.Call(Hash.PLAY_FACIAL_ANIM, p, "coughing_1", facialLib);
- else
- {
- Function.Call(Hash.PLAY_PAIN, p, 8, 1, 0f);
- Function.Call(Hash.PLAY_FACIAL_ANIM, p, "burning_1", facialLib);
- }
- execTime[i] = now;
- if (setBlipsOnInjuredPeds)
- UpdateBlip(p);
- }
- }
- foreach (Ped p in injuredRmv)
- {
- int idx = injured.IndexOf(p);
- if (idx >= 0)
- {
- injured.RemoveAt(idx);
- execTime.RemoveAt(idx);
- }
- Function.Call(Hash.DISABLE_PED_PAIN_AUDIO, p, true);
- RemoveBlip(p);
- }
- injuredRmv.Clear();
- }
- private void UpdateBlip(Ped p)
- {
- Blip existing;
- if (blipDict.TryGetValue(p, out existing))
- {
- if (!existing.Exists() || existing.Sprite == BlipSprite.Dead)
- {
- Function.Call(Hash.REMOVE_BLIP, existing);
- blipDict.Remove(p);
- }
- }
- if (!blipDict.ContainsKey(p))
- {
- Blip b = p.AddBlip();
- b.Sprite = BlipSprite.Dead;
- b.Color = BlipColor.Yellow;
- b.Name = "Injured Ped";
- blipDict[p] = b;
- }
- }
- private void RemoveBlip(Ped p)
- {
- Blip b;
- if (blipDict.TryGetValue(p, out b))
- {
- if (b.Exists())
- {
- Function.Call(Hash.REMOVE_BLIP, b);
- }
- blipDict.Remove(p);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment