ChooChoo Trains Script

I am getting the problem where the train is just inching along for a bit and then looks like it is stuck, the horn is going. It is readjusting at all angles and barely moving along. Glitching a lot and killing anything nearby.

To help the fishtailing, setting the original direction of the train to an east / westerly orientation will help as it is jumping to the original direction.

What's with the rabbits ? I suspect they are something to do with the markers, they are visible in places like bridges and inch along with the train.

Lastly, the array railCherno looks like it is made up of objectIDs of the track, don't these change at server restart ? I initially tried mapping my street light objects this way and abandoned the method as the IDs didn't seem static..

axechoochoo.jpg
 
I put together a very RAW video, don't mind my camera skillz. I noticed the train parking and switching at Elektro puts it on the platform too along with A LOT of fishtailing. Might want to look at something other than the TAN functions.

I also keep getting "Sound engine not found" when I log in to the game. I checked the paths. Looks fine.

Hmm.

The reason the train acts like that is probabley because multiple people are running the train code at the same time. Originally the code by zonekiller have the server run the server (which causes lag anywhere from a bit to a lot). I redesigned the code so the train is suppose to run by one of the people in the server and if that person disconnects another guy runs the train.

Try increasing the sleep time:

Code:
        while {true} do
        {
            _pos = getPos _train;
            //sleep 15;
            sleep 30;
            if ((_pos distance _train) < 10) then
            {
                terminate dayz_locationCheck;
                {
                    deleteVehicle _x;
                } foreach (nearestObjects [[6684,2781], ["land_cncblock_stripes", "hiluxwreck"], 10] + nearestObjects [[7976,3288], ["uazwreck"], 10]);
                _this spawn chooChooCode;
            };
        };

or you can do a "double" check

Code:
        while {true} do
        {
            _pos = getPos _train;
            sleep 15;
            if ((_pos distance _train) < 10) then
            {
                _pos = getPos _train;
                sleep 15;
                if ((_pos distance _train) < 10) then
                {
                    terminate dayz_locationCheck;
                    {
                        deleteVehicle _x;
                    } foreach (nearestObjects [[6684,2781], ["land_cncblock_stripes", "hiluxwreck"], 10] + nearestObjects [[7976,3288], ["uazwreck"], 10]);
                    _this spawn chooChooCode;
                };
            };
        };
 
The reason the train acts like that is probabley because multiple people are running the train code at the same time.
Funny thing is, I was the only one on the server when I recorded that video. I'll try your suggestions tonight. Thanks for the response.

What about the "Engine" sound not being found? Anyone else get this or fix it?
 
Likewise, just me on my test server. Hangender, what do you think to detecting the next bit of track with nearestObject and a bit of direction filtering and using that as the next track to go to, for the train. Could lead to some interesting train routes. Worldspaces could be used for horn beeping (or near to player) and for places to stop..? Am tempted to have a play with it later, would remove the need for 'mapping' the track out..
 
Funny thing is, I was the only one on the server when I recorded that video. I'll try your suggestions tonight. Thanks for the response.

What about the "Engine" sound not being found? Anyone else get this or fix it?
The engine sound not found is going to be a bad reference in sounds.hpp, check the path is valid to the sound file.. I have moved mine and am now using
Code:
sound[] = {"\train\Sounds\trainhorn", db-1, 1.0};
which is odd as it doesn't have an extension for the file, still works though, maybe a .wss doesn't require it.
 
Just had a mate join the test server and when I joined back in the train was Choo chooing down the track. I noticed the carriages hanging over the track on corners, assume thus is because they are attached to the engine. Was fine until it got back to cherno then got confused turning round. There is an army blockade over the tracks, assuming this is supposed to be there and not blocking the train..?
 
when the train "turns around" (reaches end of track in cherno/electro) it does go a bit crazy but during normal tracks it should behave like a normal train (tested on my 3 servers)

Also the train and its carriages floats on the track most of the time because of the inherent ghetto-ness of the code (arma 2 doesnt support trains): The train is attached to a rabbit which is moved around via setvelocity
 
Found my sound issue after looking at the example pbo... the new class has to be the VERY last thing.. I assumed it needed to be within the brackets with all the other classes. My bad... Now, I also included the additional delay as suggested and the train ran slightly smoother for a short period, all be it, it ran like there was no joints between the cars and when the locomotive turned, everything stayed directly behind it instead of on the tracks. Later, the train started to fish tail again and then spit the cars all over. I had a player try to approach the train and it lagged them out so bad they got disconnected. I also tried to climb on, and it is hard to find a climb on spot and when i did, I got on for a few seconds, was hurt and then left behind. Doesn't seem viable as a transport, more novelty at this point. Not sure I plan to leave it in.
 
I know this is about trains, and the train is something that works cool as hell, but have you thought about making a buss that drives around or along that main kam,bal,chern,lektro road ? a bus I would imagine would be a lot easier to code as its a vehicle already and would simply need to follow some waypoints..
 
hi , do i have to press anything to get the train to start plz?, Ive done everything iy says but cant see no train :(

thx robbie
 
Trains seem to be working. Have the same issue with the rear car swinging around. Really hope this can get working better. Always wanted working trains.
 
Everything works great pity that the player is not in the car at the time of the train. Can it be done? And how to increase the waiting time for trains?
 
Been playing with this script:

The key difference with this is that the script I am working on finds the track from the server and decides the next one to use. Damn setVelocity command has driven me to pulling my hair out though, can find and choose the next bit of track, getting the train onto it though is another thing entirely, BIS better have a special padded room prepared for me by the time i finish this..

The video shows the train at about Prigorodky, have had the train going past Elkrozavodsk and beyond. You can see how slow and jerky it is, I think I may have an idea as to the cause..

Benefits from having the train choose it's own track is then having the ability to make decisions at the points, so the train could be diverted (a long way off yet tho), no reason why a player couldn't be attached to the train and have some control over it.

I have made the train server side and the sounds client side, a big light on the front is next, obviously :) credits to Hangender and Zonekiller for their previous work on this..
 
Back
Top