[RELEASE] FiveM Freight train (AI) and enterable trams (as passenger) (Suited for Roleplay to)

And thanks ofcourse :smiley:

1 Like
2 Likes

Thanks! will definitly look into that one tomorrow! :smiley: (it’s nearly 6AM here now and i’m still working on safehouses and garages with virtual interiors at the moment so a bit ‘in the middle of heavy stuff’ haha while also having to appear at the office tomorrow at 13:00 for a staff meeting whahah

Lol Take your time. Man. Have fun and thanks

1 Like

Thank you!!! I’ve been looking for this every since the original creator gave it up! You are amazing!!! God Bless you man!

1 Like

So here is what I found so far. RealAItraffic was stopping the script from loading fully. I was only getting train models loaded. After disabling real ai traffic, The script loads fully, BUT the train still just sits there with no errors. I went through all my other scripts with no success. Also the trais are still on the wrong track.

Hmmm, okay well can you link me to RealAiTraffic to? (the one you’re using?) So i could see IF it refrences the trains, railroads and/or which natives it might use (since then i might get a step closer to understanding which natives might or will affect the trains and rail roads).

It’s strange though that they don’t start driving since the spawn command i’m using (for the trains) is also the same one that instantly initiates the Train Script (“CreateMissionTrain”).

Are you 100% certain that you don’t have any other scripts/modules that are intended to '‘kill off’ ‘default game missions’ or ‘default mini interactions’?

As for the freight spawning in the wrong location, can you try to change this line:
Train = CreateMissionTrain(math.random(0,22), x,y,z,yesorno)
to
Train = CreateMissionTrain(math.random(0,22), 1164.0, 6433.0, 32.0, true)

This will force the freight to spawn in a standard location (always the same) and
will always make it go the same direction…

Let’s see if that helps… officially the Freight should not be able to spawn on the
Metro line with my code, so trying to figure out what is causing it (or which native messes it up for example)

Thanks man :), Although keep in mind that it turns out that some still do have issues with the trains de-spawning randomly, however i will do my best in my spare time to try and solve that issue to :slight_smile:

Okay turns out i’m even ‘screwed more’ than i thought :rofl:
The trains are even affected by car handling (meta file ONLY) mods :frowning:

Well what if you add this section for the Metro:

Summary
<Item type="CHandlingData">
      <handlingName>metrotrain</handlingName>
      <fMass value="25000.000000" />
      <fInitialDragCoeff value="1.000000" />
      <fPercentSubmerged value="90.000000" />
      <vecCentreOfMassOffset x="0.000000" y="0.000000" z="1.000000" />
      <vecInertiaMultiplier x="1.000000" y="1.000000" z="1.000000" />
      <fDriveBiasFront value="0.000000" />
      <nInitialDriveGears value="4" />
      <fInitialDriveForce value="0.200000" />
      <fDriveInertia value="1.000000" />
      <fClutchChangeRateScaleUpShift value="1.300000" />
      <fClutchChangeRateScaleDownShift value="1.300000" />
      <fInitialDriveMaxFlatVel value="80.000000" />
      <fBrakeForce value="5.000000" />
      <fBrakeBiasFront value="0.500000" />
      <fHandBrakeForce value="0.700000" />
      <fSteeringLock value="35.000000" />
      <fTractionCurveMax value="2.500000" />
      <fTractionCurveMin value="0.800000" />
      <fTractionCurveLateral value="8.000000" />
      <fTractionSpringDeltaMax value="0.150000" />
      <fLowSpeedTractionLossMult value="0.000000" />
      <fCamberStiffnesss value="0.000000" />
      <fTractionBiasFront value="0.500000" />
      <fTractionLossMult value="1.000000" />
      <fSuspensionForce value="0.400000" />
      <fSuspensionCompDamp value="1.300000" />
      <fSuspensionReboundDamp value="1.000000" />
      <fSuspensionUpperLimit value="0.350000" />
      <fSuspensionLowerLimit value="-0.100000" />
      <fSuspensionRaise value="0.000000" />
      <fSuspensionBiasFront value="0.500000" />
      <fAntiRollBarForce value="0.000000" />
      <fAntiRollBarBiasFront value="0.000000" />
      <fRollCentreHeightFront value="0.000000" />
      <fRollCentreHeightRear value="0.000000" />
      <fCollisionDamageMult value="1.000000" />
      <fWeaponDamageMult value="1.000000" />
      <fDeformationDamageMult value="0.800000" />
      <fEngineDamageMult value="1.500000" />
      <fPetrolTankVolume value="0.000000" />
      <fOilVolume value="0.000000" />
      <fSeatOffsetDistX value="0.000000" />
      <fSeatOffsetDistY value="0.000000" />
      <fSeatOffsetDistZ value="0.000000" />
      <nMonetaryValue value="110000" />
      <strModelFlags>40008008</strModelFlags>
      <strHandlingFlags>8840</strHandlingFlags>
      <strDamageFlags>20</strDamageFlags>
      <AIHandling>AVERAGE</AIHandling>
      <SubHandlingData>
        <Item type="CBaseSubHandlingData" />
        <Item type="NULL" />
        <Item type="NULL" />
      </SubHandlingData>
    </Item>

And these two for the freight train and it’s carts:

Summary
 <Item type="CHandlingData">
      <handlingName>FREIGHT</handlingName>
      <fMass value="25084.000000" />
      <fInitialDragCoeff value="1.000000" />
      <fPercentSubmerged value="90.000000" />
      <vecCentreOfMassOffset x="0.000000" y="0.000000" z="1.000000" />
      <vecInertiaMultiplier x="1.000000" y="1.000000" z="1.000000" />
      <fDriveBiasFront value="0.000000" />
      <nInitialDriveGears value="4" />
      <fInitialDriveForce value="0.200000" />
      <fDriveInertia value="1.000000" />
      <fClutchChangeRateScaleUpShift value="1.300000" />
      <fClutchChangeRateScaleDownShift value="1.300000" />
      <fInitialDriveMaxFlatVel value="80.000000" />
      <fBrakeForce value="5.000000" />
      <fBrakeBiasFront value="0.500000" />
      <fHandBrakeForce value="0.700000" />
      <fSteeringLock value="35.000000" />
      <fTractionCurveMax value="2.500000" />
      <fTractionCurveMin value="0.800000" />
      <fTractionCurveLateral value="8.000000" />
      <fTractionSpringDeltaMax value="0.150000" />
      <fLowSpeedTractionLossMult value="0.000000" />
      <fCamberStiffnesss value="0.000000" />
      <fTractionBiasFront value="0.500000" />
      <fTractionLossMult value="1.000000" />
      <fSuspensionForce value="0.400000" />
      <fSuspensionCompDamp value="1.300000" />
      <fSuspensionReboundDamp value="1.000000" />
      <fSuspensionUpperLimit value="0.350000" />
      <fSuspensionLowerLimit value="-0.100000" />
      <fSuspensionRaise value="0.000000" />
      <fSuspensionBiasFront value="0.500000" />
      <fAntiRollBarForce value="0.000000" />
      <fAntiRollBarBiasFront value="0.000000" />
      <fRollCentreHeightFront value="0.000000" />
      <fRollCentreHeightRear value="0.000000" />
      <fCollisionDamageMult value="1.000000" />
      <fWeaponDamageMult value="1.000000" />
      <fDeformationDamageMult value="0.800000" />
      <fEngineDamageMult value="1.500000" />
      <fPetrolTankVolume value="0.000000" />
      <fOilVolume value="0.000000" />
      <fSeatOffsetDistX value="0.000000" />
      <fSeatOffsetDistY value="0.000000" />
      <fSeatOffsetDistZ value="0.000000" />
      <nMonetaryValue value="110000" />
      <strModelFlags>40008008</strModelFlags>
      <strHandlingFlags>C008840</strHandlingFlags>
      <strDamageFlags>20</strDamageFlags>
      <AIHandling>AVERAGE</AIHandling>
      <SubHandlingData>
        <Item type="NULL" />
        <Item type="NULL" />
        <Item type="NULL" />
      </SubHandlingData>
    </Item>
    <Item type="CHandlingData">
      <handlingName>FREIGHTCAR</handlingName>
      <fMass value="25084.000000" />
      <fInitialDragCoeff value="1.000000" />
      <fPercentSubmerged value="90.000000" />
      <vecCentreOfMassOffset x="0.000000" y="0.000000" z="0.000000" />
      <vecInertiaMultiplier x="1.000000" y="1.000000" z="1.000000" />
      <fDriveBiasFront value="0.000000" />
      <nInitialDriveGears value="4" />
      <fInitialDriveForce value="0.200000" />
      <fDriveInertia value="1.000000" />
      <fClutchChangeRateScaleUpShift value="1.300000" />
      <fClutchChangeRateScaleDownShift value="1.300000" />
      <fInitialDriveMaxFlatVel value="80.000000" />
      <fBrakeForce value="5.000000" />
      <fBrakeBiasFront value="0.500000" />
      <fHandBrakeForce value="0.700000" />
      <fSteeringLock value="35.000000" />
      <fTractionCurveMax value="2.500000" />
      <fTractionCurveMin value="0.800000" />
      <fTractionCurveLateral value="8.000000" />
      <fTractionSpringDeltaMax value="0.150000" />
      <fLowSpeedTractionLossMult value="0.000000" />
      <fCamberStiffnesss value="0.000000" />
      <fTractionBiasFront value="0.500000" />
      <fTractionLossMult value="1.000000" />
      <fSuspensionForce value="0.400000" />
      <fSuspensionCompDamp value="1.300000" />
      <fSuspensionReboundDamp value="1.000000" />
      <fSuspensionUpperLimit value="0.350000" />
      <fSuspensionLowerLimit value="-0.100000" />
      <fSuspensionRaise value="0.000000" />
      <fSuspensionBiasFront value="0.500000" />
      <fAntiRollBarForce value="0.000000" />
      <fAntiRollBarBiasFront value="0.000000" />
      <fRollCentreHeightFront value="0.000000" />
      <fRollCentreHeightRear value="0.000000" />
      <fCollisionDamageMult value="1.000000" />
      <fWeaponDamageMult value="1.000000" />
      <fDeformationDamageMult value="0.800000" />
      <fEngineDamageMult value="1.500000" />
      <fPetrolTankVolume value="0.000000" />
      <fOilVolume value="0.000000" />
      <fSeatOffsetDistX value="0.000000" />
      <fSeatOffsetDistY value="0.000000" />
      <fSeatOffsetDistZ value="0.000000" />
      <nMonetaryValue value="110000" />
      <strModelFlags>40008008</strModelFlags>
      <strHandlingFlags>8840</strHandlingFlags>
      <strDamageFlags>20</strDamageFlags>
      <AIHandling>AVERAGE</AIHandling>
      <SubHandlingData>
        <Item type="NULL" />
        <Item type="NULL" />
        <Item type="NULL" />
      </SubHandlingData>
    </Item>

to the handling.meta of your RealAI mod?
you can add both parts all the way at the bottom just above these two lines:

_</HandlingData>_
_</CHandlingDataMgr>_

I suspect that that MIGHT help to solve compatibilty issues with that mod though.

Edit:
Hmm i just noticed it used

  </AIHandlingInfos>
</CAIHandlingInfoMgr>

Instead of the mentioned lines above (which i got from the common.rpf of GTA),
So not 100% certain whats going on there, but try it anyway if you want, to see
if it has any effect OR messes up your AI mod (we only know if we try haha).
As for handling files: I don’t ‘mess’ with them that much since it’s just not my
personal interest, so I have little know how on how the game handles them
or what it does with them exactly.

I know how to add and “fine-tune” vehicles i’ve made myself (well for SA-MP and IV
mostly but that’s about it, and even then i will need a template for it haha)

So i tried it in the mod and still stops the script from loading fully. I then tried to replace in my handling mod in case it was different, and still the train just sits there. Going through scripts again looking for any mission stuff.

Damn :(, The trains de-spawning i can understand now (since it appears that for some reason the game loses sync or the ‘missionscript’ on the trains for some (native) reason.

But something that does allow them to spawn but does not allow them to run
(or resume) their MissionScript without any reason is something i don’t understand
yet. I do really think there is something causing the mission scrip (of CreateMissionTrain) to stop working.

Looks like I may have to start from a fresh server and install one thing at a time until the train script breaks. Don’t know what else to do.

Oeh damn, well if you have an easy ‘home server solution’ (hosting on your pc in a sepperate folder) AND the spare time to try and WANTING to try… okay…

But else please don’t waste to much of your time on my script :slight_smile: (although it’s highly
appreciated of course!) :slight_smile:

Cool! I’ll try this out later!

Thanks, Keep in mind though that there are currently some issues with natives of the game itself which might/will cause the trains to de-spawn at some point.

It doesn’t happen all the time or for everyone though, so i will need to find out what
native functions of the game itself messes up my trains at the moment :slight_smile:

Thanks, Keep in mind though that there are currently some issues with natives of the game itself which might/will cause the trains to de-spawn at some point.

It doesn’t happen all the time or for everyone though, so i will need to find out what
native functions of the game itself messes up my trains at the moment :slight_smile:

So I just created a bare bones server which is local and only has the train script running. No errors Fully loaded (It looks like) and the train is still not moving. Nothing else installed or running. So confused. Also have the latest artifacts. So i guess that eliminates another script causing the issue. Should it work with only me on the server?

HUH?? Now i don’t get it at all haha, do you have any asi mods or so loaded (Lambada works fine and so does Devtools btw since i use them during development).

What if you would use the /XNLForceTrains command?
and then stand at location of the first metro station, will it spawn then (just tell me if you don’t know where to find it and how to find it (the first spawn of the metro)

I found the freight train and it just sits there. Nothing eles, no trainers or anything is installed.

1 Like