Railway line
#1

Is it possible to recreate a kind of "train" with a random object that follows the same route as the San Andreas railway?
Reply
#2

No. Because even native samp mapped railway objects doesnt support it.
Reply
#3

Thank you for clarifying my doubt.
Reply
#4

Of course it is possible. If it's an object that you can use as train (not an actual train vehicle) you can move it wherever you want.
The coords of the original train lines are somewhere in the data/maps directory. If you want to build your own railroad track you can make a path for it.
Reply
#5

Yes, it is possible.
Reply
#6

Quote:
Originally Posted by NaS
Посмотреть сообщение
Of course it is possible. If it's an object that you can use as train (not an actual train vehicle) you can move it wherever you want.
The coords of the original train lines are somewhere in the data/maps directory. If you want to build your own railroad track you can make a path for it.
I did some research and was able to detect the use of the files of rail in GTA

Grand Theft Auto/data/Paths

From what I saw: the first line serves to indicate the number of cordenades
and the last line is totally empty

tracks.dat: The default path around San Andreas, containing 926 rows of coordinates XYZ & 0 at the end (I do not know what that 0 is for)
tracks2.dat: Route between the San Fierro station and the ocean port
tracks3.dat: it's the San Fierro cable car
tracks4.dat: It is only for missions

I imagine it is possible to make an object follow the course using the original data of "tracks.dat"

I think of creating a three-dimensional Array with the coordinates X, Y and Z (tracks.dat)

And make the object move at each point to point. Is it possible?
Reply
#7

Quote:
Originally Posted by DarkBr
Посмотреть сообщение
I did some research and was able to detect the use of the files of rail in GTA

Grand Theft Auto/data/Paths

From what I saw: the first line serves to indicate the number of cordenades
and the last line is totally empty

tracks.dat: The default path around San Andreas, containing 926 rows of coordinates XYZ & 0 at the end (I do not know what that 0 is for)
tracks2.dat: Route between the San Fierro station and the ocean port
tracks3.dat: it's the San Fierro cable car
tracks4.dat: It is only for missions

I imagine it is possible to make an object follow the course using the original data of "tracks.dat"

I think of creating a three-dimensional Array with the coordinates X, Y and Z (tracks.dat)

And make the object move at each point to point. Is it possible?
Yes.
You can use sscanf to parse the files easily. Either load them everytime you start the server into an array, or output the data as array to put it into your mode directly (the first will make it easier to edit, but considering the track won't change you will probably never need to do that anyway).

Then you can just create an object and move it from node to node.
May be a bit hard to find a good object for it, but the movement etc is really easy to do.

You also need to calculate the object's rotation for each node. So if the object moves for example from Node 40 to 41 you can use atan2 and acos to get the angle between the coords of those nodes.
I can give you an example for that if you wish.

One thing however is that trains (the vehicles) move on the track by two axes per wagon. So each end of the train wagon follows the track just like a real train.
An object just has one axis to rotate around, which is most likely the center. So the rotation while moving might look a bit wrong compared to actual trains.

This is fixable but a bit tricky since you need to rearrange the nodes to make the rotation happen only on the actual turn, not while approaching the turn. The easiest fix would be doubling the amount of nodes, so that there is one node in between two turns and one exactly where the rail bends. But I'd do that later, and only if the current result is not satisfying enough.
Reply
#8

Quote:
Originally Posted by NaS
Посмотреть сообщение
Yes.
You can use sscanf to parse the files easily. Either load them everytime you start the server into an array, or output the data as array to put it into your mode directly (the first will make it easier to edit, but considering the track won't change you will probably never need to do that anyway).

Then you can just create an object and move it from node to node.
May be a bit hard to find a good object for it, but the movement etc is really easy to do.

You also need to calculate the object's rotation for each node. So if the object moves for example from Node 40 to 41 you can use atan2 and acos to get the angle between the coords of those nodes.
I can give you an example for that if you wish.

One thing however is that trains (the vehicles) move on the track by two axes per wagon. So each end of the train wagon follows the track just like a real train.
An object just has one axis to rotate around, which is most likely the center. So the rotation while moving might look a bit wrong compared to actual trains.

This is fixable but a bit tricky since you need to rearrange the nodes to make the rotation happen only on the actual turn, not while approaching the turn. The easiest fix would be doubling the amount of nodes, so that there is one node in between two turns and one exactly where the rail bends. But I'd do that later, and only if the current result is not satisfying enough.
I thought of that later, it's easier to put the "tracks.dat" in the scriptfiles directory and read them and tweak them with sscanf, as you say.

It's quite tricky even to get a good object for it. I'm going to test here with some object and see if I can show off with a "train"
Reply
#9

You can't do that what are you talking about? That's in client files
Reply
#10

Quote:
Originally Posted by Croheart
Посмотреть сообщение
You can't do that what are you talking about? That's in client files
He's not trying to alter the railroad paths. He's using an object as a replacement for a train and move that along the path, using the path data from GTA's files!
Reply
#11

Quote:
Originally Posted by Croheart
Посмотреть сообщение
You can't do that what are you talking about? That's in client files
As NaS said. I copied "Tracks.dat" to 'scriptfiles' and made some basic changes, so I could use it as a kind of 'train'. And it worked!


Video^
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)