Log in to reply
 

How can i spawn a train and make it move on tracks in c# script?



  • i tried using this Function
    Function.Call(Hash.CREATE_MISSION_TRAIN, "freight", Game.Player.Character.Position.X, Game.Player.Character.Position.Y, Game.Player.Character.Position.Z, 0);
    But it just crashes my game, any idea how to do this?



  • You requested the train first?



  • @JohnFromGWN yes
    freightcarmodel = new Model("freightcar");
    freightcarmodel.Request(10000);
    trainmodel = new Model("freight");
    trainmodel.Request(10000);
    freightgrainmodel = new Model("freightgrain");
    freightgrainmodel.Request(10000);
    freightcont1model = new Model("freightcont1");
    freightcont1model.Request(10000);
    freightcont2model = new Model("freightcont2");
    freightcont2model.Request(10000);
    freighttrailermodel = new Model("freighttrailer");
    freighttrailermodel.Request(10000);
    if (Function.Call<bool>(Hash.HAS_MODEL_LOADED, trainmodel))
    {
    UI.Notify("LOADED 1");

                                        if (Function.Call<bool>(Hash.HAS_MODEL_LOADED, freightcarmodel))
                                        {
                                        UI.Notify("LOADED 2");
                                        if (Function.Call<bool>(Hash.HAS_MODEL_LOADED, freightgrainmodel))
                                            {
                                            UI.Notify("LOADED 3");
                                            if (Function.Call<bool>(Hash.HAS_MODEL_LOADED, freightcont1model))
                                                {
                                                UI.Notify("LOADED 4");
                                                if (Function.Call<bool>(Hash.HAS_MODEL_LOADED, freightcont2model))
                                                    {
                                                    UI.Notify("LOADED 5");
                                                    if (Function.Call<bool>(Hash.HAS_MODEL_LOADED, freighttrailermodel))
                                                        {
                                                        testingindex = 20;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    
                                }
    

    Vector3 c = Function.Call<Vector3>(Hash.GET_ENTITY_COORDS, Game.Player.Character, false);
    trainveh = Function.Call<Vehicle>(Hash.CREATE_MISSION_TRAIN, 24, c.X, c.Y, c.Z, 1);
    testingindex = 30;


Log in to reply
 

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.