### Goal of this PR
Allows for the creation of functioning trains on the serv…er side, this allows for trains to function as intended in `sv_entityLockdown relaxed` and `sv_entityLockdown strict`, which was a concern brought up in #2197 and https://forum.cfx.re/t/trains-with-lockdown-mode-strict-and-onesync-infinity/4831470
### How is this PR achieving the goal
By implementing a ``CREATE_TRAIN`` native to create the train engine and a ``CREATE_TRAIN_CARRIAGE`` native to create carriages for the engine of the train. Due to the lack of knowledge of train configuration and train tracks, the user will be required to populate these fields themselves. Validation is done on the server side to prevent invalid values from being used that would cause unintended behaviour and/or client crashes (e.g. invalid train configuration index).
In order to have server created trains behave as expected changes have been made to the client to set the trains track node relative to its position then force blend on ownership change (if the server was the owner) if the trains track node is 0, from testing this has no negative effect on client (tested on multiple clients) created trains and doesn't effect trains that are owned by other players.
While creating this PR I completed the ``CTrainGameStateDataNode`` from research provided by [gottfriedleibniz](https://forum.cfx.re/t/train-carriages-becoming-detached/3430416/8?u=ehbw) along side research of my own.
Valid and Invalid Examples of these natives:
```lua
local coords = vec3(193.196, -603.836, 16.7565)
--- Valid Examples
-- Creates a metrotrain that matches trainConfigIndex 24 (25 on >2372, 26 on >2802)
local entity = CreateTrain(`metrotrain`, coords.x, coords.y, coords.z, true, true, 25.0, 3, 25 -- [[>b2372]])
-- 10.79 units behind the engine carriage, matches CREATE_MISSION_TRAIN distance.
-- This carriage direction is flipped on the client-side as 'flip_model_dir' is true for this carriage in trains.xml
CreateTrainCarriage(entity, `metrotrain`, 10.79)
-- Node 0 in track id 0
local coords = vec3(139.885712, -1751.670288, 28.454244)
-- Creates a long freight train consisting of 11 freightcars
local entity = CreateTrain(`freight`, coords.x, coords.y, coords.z, true, false, 30.0, 0, 22)
CreateTrainCarriage(entity, `freightcar`, 17.52)
CreateTrainCarriage(entity, `freightcar`, 36.06)
CreateTrainCarriage(entity, `freightcar`, 54.59)
CreateTrainCarriage(entity, `freightcar`, 73.13)
CreateTrainCarriage(entity, `freightcar`, 91.66)
CreateTrainCarriage(entity, `freightcar`, 110.20)
CreateTrainCarriage(entity, `freightcar`, 128.73)
CreateTrainCarriage(entity, `freightcar`, 147.26)
CreateTrainCarriage(entity, `freightcar`, 165.80)
CreateTrainCarriage(entity, `freightcar`, 184.33)
CreateTrainCarriage(entity, `freightcar`, 202.87)
-- Creates the same freight train but moving backwards
local entity = CreateTrain(`freight`, coords.x, coords.y, coords.z, false, false, 30.0, 0, 22)
CreateTrainCarriage(entity, `freightcar`, 17.52)
CreateTrainCarriage(entity, `freightcar`, 36.06)
CreateTrainCarriage(entity, `freightcar`, 54.59)
....
-- Creates a "metrotrain" out of a freight engine and freightcar
local entity = CreateTrain(`freight`, trainData.x, trainData.y, trainData.z, true, true, 25.0, 3, metroIndex)
local train2 = CreateTrainCarriage(entity, `freightcar`, 10.779)
-- Creates a metrotrain thats starts around node 1496 on track 3, and at a reduce cruise speed (8.0f)
local entity = CreateTrain(`metrotrain`, -7.213, -1626.263, 28.673, true, true, 8.0, 3, metroIndex)
local train2 = CreateTrainCarriage(entity, `metrotrain`, 10.779)
-- Creates a metrotrain that doesn't stop at stations
local entity = CreateTrain(`metrotrain`, -7.213, -1626.263, 28.673, false, true, 25.0, 3, metroIndex)
CreateTrainCarriage(entity, `metrotrain`, 10.779)
--- Invalid examples
-- Throws an error since trackID is nil when it cannot be, (otherwise unintended behaviour occurs)
local entity = CreateTrain(`metrotrain`, coords.x, coords.y, coords.z, true, true, 25.0, nil, 25)
-- Throws an error since trainConfigIndex is nil when it cannot be, (otherwise unintended behaviour occurs)
entity = CreateTrain(`metrotrain`, coords.x, coords.y, coords.z, true, true, 25.0, 3, nil)
-- Throws an error since trainConfigIndex is invalid (e.g. less then 0 or greater then the 24 (>b1604), 25 (>b2372), 26 (>b2802)) as otherwise user client's will crash
-- "Tried to spawn train with invalid train config index: "
entity = CreateTrain(`metrotrain`, coords.x, coords.y, coords.z, true, true, 25.0, 3, 27)
-- Throws an error since 'trackId' is invalid (e.g. not 3 and not 0)
-- "Tried to spawn train on invalid track id: 4"
entity = CreateTrain(`metrotrain`, coords.x, coords.y, coords.z, true, true, 25.0, 4, 24)
-- Throws an error since the entity does not exist
-- "Tried to access invalid entity: 4321"
CreateTrainCarriage(4321, `metrotrain`, 10.79, true)
-- Throws an error since the entity is not a train
local coords = vec3(193.196, -603.836, 16.7565)
local baller = CreateVehicleServerSetter(`baller`, "automobile", coords.x, coords.y, coords.z, 0.0)
-- "Entity is not a train: (ballerID)"
CreateTrainCarriage(baller, `metrotrain`, 4, true)
-- Throws an error since the entity lacks CTrainGameStateDataNode sync node (as a result of engine carriage being created through CREATE_AUTOMOBILE, CREATE_VEHICLE_SERVER_SETTER or CREATE_VEHICLE RPC call)
local invalidTrain = CreateVehicleServerSetter(`metrotrain`, "train", coords.x, coords.y, coords.z, 0.0)
-- "Tried to attach train carriage to invalid train entity: (invalidTrainID)"
CreateTrainCarriage(invalidTrain, `metrotrain`, 10.79, true)
```
### This PR applies to the following area(s)
FiveM, Server, Natives
### Successfully tested on
it should be noted that on builds 1604, 2060 and 2189, all (client and server created) trains are removed by population upon leaving all player scopes (Deletion Reason 1 from ``ADD_VEHICLE_DELETION_TRACE``). Aside from this server created trains behave as intended on these builds.
**Game builds:** 1604, 2060, 2189, 2372, 2699, 2802, 2944, 3095
**Platforms:** Windows
### Checklist
- [x] Code compiles and has been tested successfully.
- [x] Code explains itself well and/or is documented.
- [x] My commit message explains what the changes do and what they are for.
- [x] No extra compilation warnings are added by these changes.
### Fixes issues
resolves #2197