veers 1 Posted August 26, 2018 Hi! The createMissionTrain command crashes the server. I don't know if it's my fault or the command's. Share this post Link to post Share on other sites
veers 1 Posted August 26, 2018 mp.events.add("playerCommand", (command) => { const args = command.split(/[ ]+/); const commandName = args[0]; args.shift(); if (commandName === "train") { mp.game.vehicle.createMissionTrain(15, 1838.1046142578125, 3528.820556640625, 38.384864807128906, true); } }); Share this post Link to post Share on other sites
veers 1 Posted August 27, 2018 I solved the problem but there is another one. When i try to use the 'vehicle.setTrainSpeed' script command i get an error that 'vehicle.setTrainSpeed' is not a function. I do not know how to stop the train. What's the problem with that command? Share this post Link to post Share on other sites
Hanvod 9 Posted August 27, 2018 1 час назад, veers сказал: I solved the problem Please, provide us a solution. Share this post Link to post Share on other sites
veers 1 Posted August 27, 2018 Train models have to be loaded before you use the script command. mp.game.streaming.requestModel(mp.game.joaat("freight")); mp.game.streaming.requestModel(mp.game.joaat("freightcar")); mp.game.streaming.requestModel(mp.game.joaat("freightgrain")); mp.game.streaming.requestModel(mp.game.joaat("freightcont1")); mp.game.streaming.requestModel(mp.game.joaat("freightcont2")); mp.game.streaming.requestModel(mp.game.joaat("freighttrailer")); 1 Share this post Link to post Share on other sites
veers 1 Posted August 28, 2018 So anyone could help with vehicle.setTrainSpeed error? Share this post Link to post Share on other sites
Hanvod 9 Posted August 28, 2018 (edited) 2 часа назад, veers сказал: So anyone could help with vehicle.setTrainSpeed error? createMissionTrain returns you a vehicle object. You need to write it to variable or constant, and then call setTrainSpeed method. var train mp.events.add("playerCommand", (command) => { const args = command.split(/[ ]+/); const commandName = args[0]; args.shift(); if (commandName === "train") { train = mp.game.vehicle.createMissionTrain(15, 1838.1046142578125, 3528.820556640625, 38.384864807128906, true); } if(commandName === "setTrainSpeed") { if(train) { train.setTrainSpeed(parseInt(args[1])) } } }); //then Edited August 28, 2018 by Hanvod Share this post Link to post Share on other sites
veers 1 Posted August 28, 2018 But mp.events.add is client-side, mp.events.addCommand is server-side. Share this post Link to post Share on other sites
Hanvod 9 Posted August 28, 2018 (edited) 5 минут назад, veers сказал: But mp.events.add is client-side, mp.events.addCommand is server-side. opps, thats true. BTW mp.events.add("playerCommand", (command) => { const args = command.split(/[ ]+/); const commandName = args[0]; const speed = parseInt(args[1]) args.shift(); if (commandName === "setTrainSpeed") { train.setTrainSpeed(speed) } }); Edited August 28, 2018 by Hanvod Share this post Link to post Share on other sites