Skip to content

Instantly share code, notes, and snippets.

@David-Lor
Created June 29, 2018 13:59
Show Gist options
  • Save David-Lor/4b06dd407130f4cfc0202908526db5f9 to your computer and use it in GitHub Desktop.
Save David-Lor/4b06dd407130f4cfc0202908526db5f9 to your computer and use it in GitHub Desktop.
gta v paratroopers wip
using GTA;
using GTA.Native;
using GTA.Math;
using System;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
public class paracas : Script
{
private bool paracasOn = false;
private List<Ped> paracasSpawneados = new List<Ped>();
private List<Ped> paracasSpawneadosBorrar = new List<Ped>();
private Vehicle heli, titan;
//private VehicleSeat[] seats = new VehicleSeat[] { VehicleSeat.Driver, VehicleSeat.ExtraSeat1, VehicleSeat.ExtraSeat10, VehicleSeat.ExtraSeat11, VehicleSeat.ExtraSeat12, VehicleSeat.ExtraSeat2, VehicleSeat.ExtraSeat3, VehicleSeat.ExtraSeat4, VehicleSeat.ExtraSeat5, VehicleSeat.ExtraSeat6, VehicleSeat.ExtraSeat7, VehicleSeat.ExtraSeat8, VehicleSeat.ExtraSeat9, VehicleSeat.LeftFront, VehicleSeat.LeftRear, VehicleSeat.Passenger, VehicleSeat.RightFront, VehicleSeat.RightRear };
private int relationship_enemigos = 0;
private int relationship_amigos = 0;
public paracas()
{
Tick += OnTick;
KeyUp += OnKeyUp;
Interval = 50;
GTA.Blip[] activeblips = GTA.World.GetActiveBlips();
foreach (Blip b in activeblips) {
b.Remove();
}
relationship_enemigos = World.AddRelationshipGroup("paracaidistas");
relationship_amigos = World.AddRelationshipGroup("player");
GTA.World.SetRelationshipBetweenGroups(Relationship.Like, relationship_enemigos, relationship_enemigos);
GTA.World.SetRelationshipBetweenGroups(Relationship.Hate, relationship_enemigos, relationship_amigos);
Game.Player.Character.RelationshipGroup = relationship_amigos;
}
void paracaVoid(Ped p1)
{
p1.Weapons.Give(WeaponHash.AssaultRifle, 1000, false, true);
p1.Weapons.Give(WeaponHash.Parachute, 1, true, true);
p1.RelationshipGroup = relationship_enemigos;
p1.AlwaysKeepTask = true;
TaskSequence ts1 = new TaskSequence();
ts1.AddTask.LeaveVehicle(heli, false);
ts1.AddTask.UseParachute();
ts1.Close(false);
p1.Task.PerformSequence(ts1);
Wait(2000);
p1.Task.ParachuteTo(Game.Player.Character.Position.Around(15f));
while (p1.IsInAir) {
Wait(50);
p1.Task.ParachuteTo(Game.Player.Character.Position.Around(15f));
}
p1.Task.FightAgainstHatedTargets(1000f);
}
void OnTick(object sender, EventArgs e)
{
if (paracasOn) {
Ped p1 = heli.CreateRandomPedOnSeat(VehicleSeat.Passenger);
Ped p2 = heli.CreateRandomPedOnSeat(VehicleSeat.Passenger);
Ped p3 = heli.CreateRandomPedOnSeat(VehicleSeat.Passenger);
Ped[] paracaidistas = new Ped[] { p1, p2, p3 };
Wait(1000);
foreach (Ped p in paracaidistas) {
paracaVoid(p);
}
Wait(10000);
}
}
void OnKeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.J) { //spawnear heli
if (!paracasOn) { //activar paracas
paracasOn = true;
Vector3 posHeli = Game.Player.Character.Position.Around(100.0f);
posHeli.Z = posHeli.Z + 200f;
heli = GTA.World.CreateVehicle(VehicleHash.Cargobob, posHeli);
Ped conductor = heli.CreatePedOnSeat(VehicleSeat.Driver, PedHash.Vagos01GFY);
conductor.AlwaysKeepTask = true;
UI.ShowSubtitle("Heli spawned, paratroopers coming ASAP!");
heli.AddBlip();
heli.CurrentBlip.Sprite = BlipSprite.HelicopterAnimated;
heli.CurrentBlip.Color = BlipColor.Green;
} else { //desactivar paracas
paracasOn = false;
heli.CurrentBlip.Remove();
heli.Delete();
UI.ShowSubtitle("Paratroopers stopped spawning, the assault is over!");
}
}
else if (e.KeyCode == Keys.H) { //spawnear un Titan
//Vector3 posTitan = Game.Player.Character.Position.Around(100.0f);
//posTitan.Z = posTitan.Z + 500.0f;
Vector3 posTitan = Game.Player.Character.Position.Around(555.0f);
posTitan.Z = posTitan.Z + 750.0f;
titan = GTA.World.CreateVehicle(VehicleHash.Titan, posTitan);
float titanHeading = titan.Heading;
Ped conductor = titan.CreatePedOnSeat(VehicleSeat.Driver, PedHash.Vagos01GFY);
TaskSequence ts = new TaskSequence();
Vector3 posTitanDestino1 = posTitan;
Vector3 posTitanDestino2 = posTitan;
posTitanDestino1.X = posTitan.X + 5000.0f;
ts.AddTask.DriveTo(titan, posTitanDestino1, 100.0f, 50.0f, 1074528293);
ts.AddTask.DriveTo(titan, posTitanDestino2, 100.0f, 50.0f);
ts.Close(true);
conductor.AlwaysKeepTask = true;
conductor.Task.PerformSequence(ts);
UI.ShowSubtitle("Titan spawneado");
titan.AddBlip();
titan.CurrentBlip.Color = BlipColor.Blue;
titan.Heading = titanHeading;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment