RedM Natives

Mission trains

Notes from the author
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------

 -- EXAMPLE OF USING:


 local current_train = nil
 local function CreateTrain(n, direction)
     if tonumber(n) then
         if n > 0 and n < 100 then
             trainHash = train_hashes[n]
         else
             trainHash = n
         end
     else
         trainHash = GetHashKey(n)
     end
     local trainWagons = Citizen.InvokeNative(0x635423D55CA84FC8, trainHash)  -- _GET_NUM_CARS_FROM_TRAIN_CONFIG(Hash trainConfig);
     for wagonIndex = 0, trainWagons - 1 do
         local trainWagonModel = Citizen.InvokeNative(0x8DF5F6A19F99F0D5, trainHash, wagonIndex)  -- _GET_TRAIN_MODEL_FROM_TRAIN_CONFIG_BY_CAR_INDEX
         Citizen.InvokeNative(0xFA28FE3A6246FC30, trainWagonModel)  -- REQUEST_MODEL
         local i = 0        
         while not Citizen.InvokeNative(0x1283B8B89DD5D1B6, trainWagonModel) and i < 100 do    --HasModelLoaded(
             Citizen.InvokeNative(0xFA28FE3A6246FC30, trainWagonModel)  -- request model
             Citizen.Wait(50)
             i=i+1
         end 
     end
     local does_train_have_passengers = 1
     local does_train_have_conductor = 1
     local train = Citizen.InvokeNative(0xC239DBD9A57D2A71, trainHash, GetEntityCoords(PlayerPedId()), direction, does_train_have_passengers, 1, does_train_have_conductor)  -- _CREATE_MISSION_TRAIN
     Citizen.Wait(500)
     current_train = train
 end
 -- SPAWN TRAIN OR DELETE TRAIN LIKE THAT:
 -- train gunslinger3_config
 -- train 0x3D72571D
 -- train 10 (creates 10th train from list "mission_trains")
 -- train delete
 RegisterCommand("train", function(source, args, raw)
     if args[1] ~= "delete" then
         print("trying to create train")
         local n = tonumber(args[1])
         if not n then
             n = GetHashKey(args[1])
         end
         if n then
             local direction = 0
             if args[2] then
                 direction = tonumber(args[2])
                 if direction == nil then
                     direction = 0
                 end
             end
             CreateTrain(n, direction)
         else
             print("wrong train hash or name")
         end
     else
         print("trying to delete train "..tostring(current_train))
         if current_train and current_train > 0 then
             local train_driver_id  = Citizen.InvokeNative(0x2963B5C1637E8A27, current_train)  -- GET_DRIVER_OF_VEHICLE
             if train_driver_id and train_driver_id ~= 0 and train_driver_id ~= PlayerPedId() then 
                 SetEntityAsMissionEntity(train_driver_id,1,1)
                 DeletePed(train_driver_id)
             end
             Citizen.InvokeNative(0x0D3630FB07E8B570, Citizen.PointerValueIntInitialized(current_train))  -- DELETE_MISSION_TRAIN
             Citizen.InvokeNative(0xA3120A1385F17FF7) -- DELETE_ALL_TRAINS   
             current_train = 0
         end
     end
 end)


------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
87 rows
#valueNote
10x005E03AD
20x0392C83A
30x0660E567
40x0941ADB7net_fetch_train_vip_rescue_00
50x09B679D6
60x0CCC2F70
70x0D03C58D
80x0E62D710ghost_train_config
90x10461E19
100x124A1F89
110x19A0A288
120x1C043595
130x1C9936BB
140x1EEC5C2A
150x1EF82A51
160x25E5D8FF
170x26509FBBdummy_engine_config
180x29C81ACB
190x2D1A6F0C
200x2D3645FA
210x31656D23
220x3260CE89engine_config
230x35D17C43
240x3ADC4DA9
250x3D72571Dgunslinger3_config
260x3EDA466Dhandcart_config
270x41436136
280x487B2BE7winter4_config
290x4A73E49C
300x4C9CCB22
310x515E31EDprisoner_escort_config
320x57C209C4
330x592A5CD0
340x5AA369CAgunslinger4_config
350x5D9928A4
360x68CF495F
370x6CC26E27
380x6D69A954
390x73722125
400x761CE0ADnet_fetch_train_camp_resupply_00
410x767DEB32industry2_config
420x7BD58C4D
430x8864D73A
440x8D0766BC
450x8EAC625Cappleseed_config
460x90CB53CA
470x9296570E
480x96563327
490x98427740
500x9897FF51
510x998A0CBC
520x9CBE6FEC
530x9E096E46
540xA3BF0BEBnet_fetch_train_kidnapped_buyer_00
550xA8B1CEB7
560xA91041A2
570xAA3E691E
580xAC18A9F4
590xAE47CA77net_fetch_train_bounty_horde_00
600xAEE0ECF5
610xB1F69614
620xBF69518Ftrolley_config
630xC1F1DD80
640xC732CDC8
650xC75AA08Cminecart_config
660xCA19C62A
670xCD2C7CA1
680xD233B18Dnet_fetch_train_moving_bounty_1
690xD42DD3EE
700xD5DF2D82
710xD8CF6395
720xD92B16AE
730xD93C36C2
740xDA2EDE2F
750xDC9DD041
760xDD920DAF
770xE0898B89
780xE16CA3EF
790xEB8B2439
800xEF9FC71D
810xEFBFBDD8
820xF19E48CA
830xF6AA98F4
840xF9B038FCbountyhunter_config
850xFAB2FFB9
860xFAC328F0
870xFD8810E8