SA-MP Forums

Go Back   SA-MP Forums > SA-MP DL Edition > SA-MP 0.3.DL

Reply
 
Thread Tools Display Modes
Old 16/11/2018, 09:35 PM   #1
DarkBr
Huge Clucker
 
Join Date: Feb 2017
Location: ∫ f(x) dx
Posts: 354
Reputation: 11
Question Railway: Track/Line/Way

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

Last edited by DarkBr; 18/11/2018 at 10:51 PM.
DarkBr is offline   Reply With Quote
Old 16/11/2018, 10:14 PM   #2
Kasis
Huge Clucker
 
Kasis's Avatar
 
Join Date: Mar 2010
Location: Weed, New Mexico
Posts: 485
Reputation: 72
Default Re: Railway line

No. Because even native samp mapped railway objects doesnt support it.
__________________
Kasis is offline   Reply With Quote
Old 16/11/2018, 11:00 PM   #3
DarkBr
Huge Clucker
 
Join Date: Feb 2017
Location: ∫ f(x) dx
Posts: 354
Reputation: 11
Default Re: Railway line

Thank you for clarifying my doubt.
DarkBr is offline   Reply With Quote
Old 17/11/2018, 02:38 AM   #4
NaS
High-roller
 
NaS's Avatar
 
Join Date: Mar 2008
Posts: 1,614
Reputation: 492
Default Re: Railway line

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.
NaS is offline   Reply With Quote
Old 17/11/2018, 06:45 AM   #5
iAmir
Big Clucker
 
iAmir's Avatar
 
Join Date: May 2017
Posts: 122
Reputation: 173
Default Re: Railway line

Yes, it is possible.
__________________
Quote:
Originally Posted by J0sh...
haha
iAmir is offline   Reply With Quote
Old 17/11/2018, 04:37 PM   #6
DarkBr
Huge Clucker
 
Join Date: Feb 2017
Location: ∫ f(x) dx
Posts: 354
Reputation: 11
Default Re: Railway line

Quote:
Originally Posted by NaS View Post
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?
DarkBr is offline   Reply With Quote
Old 17/11/2018, 05:26 PM   #7
NaS
High-roller
 
NaS's Avatar
 
Join Date: Mar 2008
Posts: 1,614
Reputation: 492
Default Re: Railway line

Quote:
Originally Posted by DarkBr View Post
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.
NaS is offline   Reply With Quote
Old 17/11/2018, 05:57 PM   #8
DarkBr
Huge Clucker
 
Join Date: Feb 2017
Location: ∫ f(x) dx
Posts: 354
Reputation: 11
Default Re: Railway line

Quote:
Originally Posted by NaS View Post
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"
DarkBr is offline   Reply With Quote
Old 18/11/2018, 11:48 PM   #9
Croheart
Big Clucker
 
Croheart's Avatar
 
Join Date: Sep 2013
Location: Šibenik
Posts: 77
Reputation: 23
Default Re: Railway line

You can't do that what are you talking about? That's in client files
Croheart is offline   Reply With Quote
Old 19/11/2018, 05:14 PM   #10
NaS
High-roller
 
NaS's Avatar
 
Join Date: Mar 2008
Posts: 1,614
Reputation: 492
Default Re: Railway line

Quote:
Originally Posted by Croheart View Post
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!
NaS is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Map] Railway station KodyL Maps 16 05/03/2017 05:42 AM
How to know which line? ATGOggy Scripting Help 9 26/01/2015 05:16 AM
New line help. kamilbam Help Archive 3 27/04/2011 06:12 PM
[Map] [FS]LS Admin Base with Runway+Tunnel+RailWay SkizzoTrick Maps 17 25/12/2010 03:58 AM
Next line Maniek Help Archive 8 23/10/2009 03:35 PM


All times are GMT. The time now is 07:19 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.