Skip to content
View in the app

A better way to browse. Learn more.

LCPDFR.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

CREATE_MISSION_TRAIN

Featured Replies

I've got several things working, and several not. I'll start a github repo tomorrow for it. 

I can't get any of the removal methods to work, although just deleting the vehicle does work. 

Here's the crux of the code: 

Game.LogTrivial("Set random trains");
NativeFunction.Natives.SetRandomTrains(0);
Game.LogTrivial("Delete trains");
NativeFunction.Natives.DeleteAllTrains();

Game.LogTrivial("Load models");

new Model("freight").LoadAndWait();
new Model("freightcar").LoadAndWait();
new Model("freightgrain").LoadAndWait();
new Model("freightcont1").LoadAndWait();
new Model("freightcont2").LoadAndWait();
new Model("freighttrailer").LoadAndWait();

Game.LogTrivial("Create train");
uint train_handle = NativeFunction.Natives.CreateMissionTrain<uint>(variation, x, y, z, direction);

Vehicle train = NativeFunction.Natives.GetTrainCarriage<Vehicle>(train_handle, 0);

Game.LogTrivial("Set speed");
NativeFunction.CallByName<uint>("SET_TRAIN_SPEED", train, 15.0f);

Game.LogTrivial("Set cruise speed");
NativeFunction.CallByName<uint>("SET_TRAIN_CRUISE_SPEED", train, 15.0f);

 

[REL] Coastal Callouts: An action-packed mod with new vehicles, maps, capabilities, and callouts in and around the waters of Los Santos

[REL] Police Tape: Make your scenes more realistic while stopping peds and traffic

[REL] Better EMS: Realistic and dynamic EMS response

Join the Parks Benefactor Program to support my work and get early beta access!

  • Replies 52
  • Views 5k
  • Created
  • Last Reply

Top Posters In This Topic

Most Popular Posts

  • alexguirre
    alexguirre

    This worked for me: new Model("freight").LoadAndWait(); new Model("freightcar").LoadAndWait(); new Model("freightgrain").LoadAndWait();

  • This thread escalated faster than i thought :)

  • Your weekend??? What about my night, I should have never brought it up :p

Posted Images

Here are the train tracks:

http://s1166.photobucket.com/user/LtFlash/library/GTA V - Train tracks?sort=3&page=1

the title indicates which file defines the track. Later I'll try to figure out the IDs of junctions :tongue:

I failed to control a junction, seems like there's not such functionality. A train, when placed on a segment of rail track, will just move straight forward when reaching the last point of track. I tested it with trains2.dat segment. Trains7.dat does not let you to leave the tracks group of LS Railyard - a train starts moving in a weird direction near the junction with the trains1.dat

Edited by LtFlash

6 hours ago, LtFlash said:

Here are the train tracks:

http://s1166.photobucket.com/user/LtFlash/library/GTA V - Train tracks?sort=3&page=1

the title indicates which file defines the track. Later I'll try to figure out the IDs of junctions :tongue:

I failed to control a junction, seems like there's not such functionality. A train, when placed on a segment of rail track, will just move straight forward when reaching the last point of track. I tested it with trains2.dat segment. Trains7.dat does not let you to leave the tracks group of LS Railyard - a train starts moving in a weird direction near the junction with the trains1.dat

Hm, very interesting. I wonder what's up with several of the tracks apparently being in the middle of the ocean? 

The switches are definitely weird. In several places, going over switches that weren't configured for the track I was on caused the train cars to just despawn as they hit the junction. Over by the quarry was especially weird; the direction of the train seemed to affect which direction it went at the switch! If the train engine was facing north, it would stay on the main track (regardless of whether the train was moving forward or backwards). If the train engine was facing south, it would take the siding into the quarry. 

In the decompiled scripts there's references to track junctions 1 through 11 being switched in various configurations. Not sure yet which switches are where. 

[REL] Coastal Callouts: An action-packed mod with new vehicles, maps, capabilities, and callouts in and around the waters of Los Santos

[REL] Police Tape: Make your scenes more realistic while stopping peds and traffic

[REL] Better EMS: Realistic and dynamic EMS response

Join the Parks Benefactor Program to support my work and get early beta access!

7 hours ago, LtFlash said:

Here are the train tracks:

http://s1166.photobucket.com/user/LtFlash/library/GTA V - Train tracks?sort=3&page=1

the title indicates which file defines the track. Later I'll try to figure out the IDs of junctions :tongue:

I failed to control a junction, seems like there's not such functionality. A train, when placed on a segment of rail track, will just move straight forward when reaching the last point of track. I tested it with trains2.dat segment. Trains7.dat does not let you to leave the tracks group of LS Railyard - a train starts moving in a weird direction near the junction with the trains1.dat

BTW... I noticed that there's a fourth parameter and I'm not sure what it is. It's usually 0, but sometimes anything from 1-4. Could you set a different color for the blips depending on that parameter? e.g. white = 0, yellow = 1, blue = 2, green = 3, red = 4? Then we could see if there's a pattern to it... perhaps it means something to do with the switches or something like that. 

[REL] Coastal Callouts: An action-packed mod with new vehicles, maps, capabilities, and callouts in and around the waters of Los Santos

[REL] Police Tape: Make your scenes more realistic while stopping peds and traffic

[REL] Better EMS: Realistic and dynamic EMS response

Join the Parks Benefactor Program to support my work and get early beta access!

6 minutes ago, PNWParksFan said:

BTW... I noticed that there's a fourth parameter and I'm not sure what it is. It's usually 0, but sometimes anything from 1-4. Could you set a different color for the blips depending on that parameter? e.g. white = 0, yellow = 1, blue = 2, green = 3, red = 4? Then we could see if there's a pattern to it... perhaps it means something to do with the switches or something like that. 

I was researching this teleporting to various points,this is what I found out:

  • 0: normal track
  • 1: platform track, the train stops here, especially used for the metro
  • 2: no idea
  • 3: I didn't find any track with this number
  • 4: track in a tunnel 

Edited by alexguirre

43 minutes ago, PNWParksFan said:

1)

Over by the quarry was especially weird; the direction of the train seemed to affect which direction it went at the switch! If the train engine was facing north, it would stay on the main track (regardless of whether the train was moving forward or backwards). If the train engine was facing south, it would take the siding into the quarry. 

2)

In the decompiled scripts there's references to track junctions 1 through 11 being switched in various configurations. Not sure yet which switches are where. 

ad.1)

I suppose that's because when train spawns with direction 1 it is being placed on one track and if direction == 0 - on another by means of trains1 big loop and trains2 segment from quarry. That is my idea for switching directions from: when player enters a trigger the train got moved from trains1 to the closest point of trains2. That's only a concept though.

ad.2)

I only tested the junction near the quarry because trains2 actually _worked_ as a railtrack. Now, after analyzing the infrastructure, I think it would be better to check the junctions in LS where tracks split to form a loop.

  • Author
49 minutes ago, LtFlash said:

ad.1)

I suppose that's because when train spawns with direction 1 it is being placed on one track and if direction == 0 - on another by means of trains1 big loop and trains2 segment from quarry. That is my idea for switching directions from: when player enters a trigger the train got moved from trains1 to the closest point of trains2. That's only a concept though.

ad.2)

I only tested the junction near the quarry because trains2 actually _worked_ as a railtrack. Now, after analyzing the infrastructure, I think it would be better to check the junctions in LS where tracks split to form a loop.

If my memory serves me correctly there was a sp mission in the quarry involving trains, which also used switching tracks, could be wrong though.

1 hour ago, LtFlash said:

ad.1)

I suppose that's because when train spawns with direction 1 it is being placed on one track and if direction == 0 - on another by means of trains1 big loop and trains2 segment from quarry. That is my idea for switching directions from: when player enters a trigger the train got moved from trains1 to the closest point of trains2. That's only a concept though.

ad.2)

I only tested the junction near the quarry because trains2 actually _worked_ as a railtrack. Now, after analyzing the infrastructure, I think it would be better to check the junctions in LS where tracks split to form a loop.

 

22 minutes ago, khorio said:

If my memory serves me correctly there was a sp mission in the quarry involving trains, which also used switching tracks, could be wrong though.

From looking at your maps it appears that trains1 and trains2 overlap on a section of track, so depending on which track you end up on when you start the mission train, it'll go different directions. Later I'll try spawning it at the precise coordinates listed in one of the dat files and the other, to see what it does. 

I looked for all instances of the switch native in the decompiled scripts and found nothing in any of the heists-related scripts. I might go to one of the switch locations and just try every switch ID from 0 to 11 and see if it works. 

[REL] Coastal Callouts: An action-packed mod with new vehicles, maps, capabilities, and callouts in and around the waters of Los Santos

[REL] Police Tape: Make your scenes more realistic while stopping peds and traffic

[REL] Better EMS: Realistic and dynamic EMS response

Join the Parks Benefactor Program to support my work and get early beta access!

  • Author

The only one i found in the decompiled ones i have is this one

Search "SWITCH_TRAIN_TRACK" (1 hit in 1 file)
  E:\_GTADEV\decompiled\main_persistent.txt (1 hit)
	Line 991:     VEHICLE::SWITCH_TRAIN_TRACK(A_0, A_1);

not much to go on

Maybe SWITCH_TRAIN_TRACK doesn't do what we think it does? 

    if (GAMEPLAY::GET_INDEX_OF_CURRENT_LEVEL() == 1) {
        if (g_17E61) {
            for (v_2 = 0; v_2 < 12; v_2 += 1) {
                sub_372d(v_2, GAMEPLAY::IS_BIT_SET(g_17E62, v_2));
            }
            g_17E61 = 0;
        }
    }

This the only place where it's called(sub_372d() is a function that only calls SWITCH_TRAIN_TRACK), apparently it only changes the tracks if the global "g_17E61" is true and if all the globals are called the same in all the decompiled scripts, it's set to true in a lot of them.
Is it possible that it disables a train track from spawing random trains? It will make sense since it accepts values from 0-11 and the train tracks are from 1-12.

  • Author
Just now, alexguirre said:

Maybe SWITCH_TRAIN_TRACK doesn't do what we think it does? 


    if (GAMEPLAY::GET_INDEX_OF_CURRENT_LEVEL() == 1) {
        if (g_17E61) {
            for (v_2 = 0; v_2 < 12; v_2 += 1) {
                sub_372d(v_2, GAMEPLAY::IS_BIT_SET(g_17E62, v_2));
            }
            g_17E61 = 0;
        }
    }

This the only place where it's called(sub_372d() is a function that only calls SWITCH_TRAIN_TRACK), apparently it only changes the tracks if the global "g_17E61" is true and if all the globals are called the same in all the decompiled scripts, it's set to true in a lot of them.
Is it possible that it disables a train track from spawing random trains? It will make sense since it accepts values from 0-11 and the train tracks are from 1-12.

That could very well be, it would make sense they only spawn trains on the track they want for missions and such..

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.