static public async Task <int> Create(TrainModels trainModel, Vector3 loc, bool npcs)
            {
                int trainWagons = API.N_0x635423d55ca84fc8((int)trainModel);

                for (int i = 0; i < trainWagons; i++)
                {
                    int trainWagonModel = API.N_0x8df5f6a19f99f0d5((int)trainModel, i);
                    await Request.Model(trainWagonModel);
                }
                int handle = Function.Call <int>((Hash)0xC239DBD9A57D2A71, trainModel, loc.X, loc.Y, loc.Z, 0, 0, 1, 1);

                API.SetTrainSpeed(handle, 0f);

                //Driver
                int trainDriverHandle = API.GetPedInVehicleSeat(handle, -1);

                while (!API.DoesEntityExist(trainDriverHandle))
                {
                    trainDriverHandle = API.GetPedInVehicleSeat(handle, -1);
                    await BaseScript.Delay(100);
                }
                Function.Call((Hash)0xA5C38736C426FCB8, trainDriverHandle, true);  // godmode
                Function.Call((Hash)0x9F8AA94D6D97DBF4, trainDriverHandle, true);  //ignore events
                Function.Call((Hash)0x63F58F7C80513AAD, trainDriverHandle, false); //can be targeted
                Function.Call((Hash)0x7A6535691B477C48, trainDriverHandle, false); // knocked out of seat

                Function.Call((Hash)0x05254BA0B44ADC16, handle, false);            // train cant be targeted
                return(handle);
            }
Beispiel #2
0
        private async void OnStartTrain()
        {
            Debug.WriteLine("The train has arrived.");

            // Remove existing trains
            API.DeleteAllTrains();

            // Load all train models
            var tasks = TrainModels.Select(model => model.Request(5000));

            bool[] success = await Task.WhenAll(tasks);

            if (!success.All((x) => x))
            {
                Debug.WriteLine("Failed to load a train model. Bailing!");
                return;
            }

            var trains = new List <int>(3);

            // Create the main train
            Vector3 spawn          = TrainSpawns.ElementAt(Random.Next(TrainSpawns.Count()));
            bool    faceForward    = Random.Next(0, 1) == 1;
            int     variation      = Random.Next(0, 22);
            int     metroVariation = 24;

            trains.Add(API.CreateMissionTrain(variation, spawn.X, spawn.Y, spawn.Z, faceForward));

            // Create metro trains
            trains.Add(API.CreateMissionTrain(metroVariation, MetroSpawn1.X, MetroSpawn1.Y, MetroSpawn1.Z, true));
            trains.Add(API.CreateMissionTrain(metroVariation, MetroSpawn2.X, MetroSpawn2.Y, MetroSpawn2.Z, true));

            // Add drivers and set as mission entities
            foreach (var train in trains)
            {
                API.CreatePedInsideVehicle(
                    train,
                    26, // Human ped type
                    (uint)DriverModel.Hash,
                    (int)VehicleSeat.Driver,
                    true,
                    true
                    );

                API.SetEntityAsMissionEntity(train, true, true);

                // Add blip to train (delete this later)
                var blip = new Blip(API.AddBlipForEntity(train))
                {
                    Color  = BlipColor.FranklinGreen,
                    Name   = "Train",
                    Sprite = BlipSprite.Tonya
                };
            }

            Debug.WriteLine("Loaded trains!");
        }
Beispiel #3
0
 private void SetupTrainModels()
 {
     TrainModels.Add(new Model(@"freight"));
     TrainModels.Add(new Model(@"freightcar"));
     TrainModels.Add(new Model(@"freightgrain"));
     TrainModels.Add(new Model(@"freightcont1"));
     TrainModels.Add(new Model(@"freightcont2"));
     TrainModels.Add(new Model(@"freighttrailer"));
     TrainModels.Add(new Model(@"tankercar"));
     TrainModels.Add(new Model(@"metrotrain"));
     TrainModels.Add(DriverModel);
 }
Beispiel #4
0
        public Task Handle(TrainModels message)
        {
            Console.WriteLine(" 1) get model information from agent");
            Console.WriteLine(" 2) call to train intent classifier");
            Console.WriteLine(" 3) call to train entity recognizer");

            _bus.Send(new CheckIntentClassifier()
            {
                Id = message.Id
            });
            _bus.Send(new CheckEntityRecognizer()
            {
                Id = message.Id
            });

            return(Task.CompletedTask);
        }
 public TrainRoute(List <Vector4> stops, List <TrackSwitch> switches, double speed, Vector3 spawn, TrainModels model, int cooldown)
 {
     this.Stops       = stops;
     this.Switches    = switches;
     this.CruiseSpeed = speed;
     this.TrainSpawn  = spawn;
     this.Cooldown    = cooldown;
     this.Model       = model;
     this.Npcs        = true;
 }