veers Posted August 28, 2018 Author Posted August 28, 2018 Type error: setTrainSpeed is not a function.
Hanvod Posted August 28, 2018 Posted August 28, 2018 Ok, I got it. Wait a little bit, I will give you a working solution. 16 минут назад, veers сказал: Type error: setTrainSpeed is not a function. Because createMissionTrain returns a handle. I found the solution, will record video, wait ~10 minutes
Hanvod Posted August 28, 2018 Posted August 28, 2018 (edited) 38 минут назад, veers сказал: Type error: setTrainSpeed is not a function. You need to call mp.game.invoke('0xAA0BC91BE0B796E3', train, speed) (SET_TRAIN_SPEED) where train is your train handle (you got it from createMissionTrain()) and speed is your speed. But when I use const speed = 5.0 it works, but if I will write speed = parseFloat(args[1]), It crashes the game. Also after you set train speed, it will accelerate back to cruise speed, so you need to call mp.game.invoke("0x16469284DB8C62B5", train, speed) (SET_TRAIN_CRUISE_SPEED) to make train speed static. Will write back when I will get solution for this crash. Edited August 28, 2018 by Hanvod
Hanvod Posted August 28, 2018 Posted August 28, 2018 UPD: looks like it doesnt matter what speed we use, It always just stops.
Hanvod Posted August 28, 2018 Posted August 28, 2018 (edited) UPD: -1 makes train go backwards very fast 🤣 Also It seems that I really need to restart my game Ok, Im just wasted 2 hours trying to figure it out. I'll try again later. Edited August 28, 2018 by Hanvod
veers Posted August 28, 2018 Author Posted August 28, 2018 Still getting "is not function" error. mp.events.add("playerCommand", (command) => { const args = command.split(/[ ]+/); const commandName = args[0]; args.shift(); if (commandName === "train") { if(!mp.game.streaming.hasModelLoaded(mp.game.joaat("freight"))) mp.game.streaming.requestModel(mp.game.joaat("freight")); while(!mp.game.streaming.hasModelLoaded(mp.game.joaat("freight"))) mp.game.wait(0); if(!mp.game.streaming.hasModelLoaded(mp.game.joaat("freightcar"))) mp.game.streaming.requestModel(mp.game.joaat("freightcar")); while(!mp.game.streaming.hasModelLoaded(mp.game.joaat("freightcar"))) mp.game.wait(0); if(!mp.game.streaming.hasModelLoaded(mp.game.joaat("freightgrain"))) mp.game.streaming.requestModel(mp.game.joaat("freightgrain")); while(!mp.game.streaming.hasModelLoaded(mp.game.joaat("freightgrain"))) mp.game.wait(0); if(!mp.game.streaming.hasModelLoaded(mp.game.joaat("freightcont1"))) mp.game.streaming.requestModel(mp.game.joaat("freightcont1")); while(!mp.game.streaming.hasModelLoaded(mp.game.joaat("freightcont1"))) mp.game.wait(0); if(!mp.game.streaming.hasModelLoaded(mp.game.joaat("freightcont2"))) mp.game.streaming.requestModel(mp.game.joaat("freightcont2")); while(!mp.game.streaming.hasModelLoaded(mp.game.joaat("freightcont2"))) mp.game.wait(0); if(!mp.game.streaming.hasModelLoaded(mp.game.joaat("freighttrailer"))) mp.game.streaming.requestModel(mp.game.joaat("freighttrailer")); while(!mp.game.streaming.hasModelLoaded(mp.game.joaat("freighttrailer"))) mp.game.wait(0); const speed = 5.0; train = mp.game.vehicle.createMissionTrain(15, 2693.93408203125, 3067.782958984375, 41.46901321411133, false); mp.game.invoke('0xAA0BC91BE0B796E3', train, speed); mp.game.invoke('0x16469284DB8C62B5', train, speed); train.setTrainSpeed(speed); train.setTrainCruiseSpeed(speed); } }); I don't know what can be the problem.
Hanvod Posted August 28, 2018 Posted August 28, 2018 mp.game.invoke calls a native, you dont need train.setTrainSpeed. var train mp.events.add("playerCommand", (command) => { const args = command.split(/[ ]+/); const commandName = args[0]; args.shift(); if (commandName === "train") { if(!mp.game.streaming.hasModelLoaded(mp.game.joaat("freight"))) mp.game.streaming.requestModel(mp.game.joaat("freight")); while(!mp.game.streaming.hasModelLoaded(mp.game.joaat("freight"))) mp.game.wait(0); if(!mp.game.streaming.hasModelLoaded(mp.game.joaat("freightcar"))) mp.game.streaming.requestModel(mp.game.joaat("freightcar")); while(!mp.game.streaming.hasModelLoaded(mp.game.joaat("freightcar"))) mp.game.wait(0); if(!mp.game.streaming.hasModelLoaded(mp.game.joaat("freightgrain"))) mp.game.streaming.requestModel(mp.game.joaat("freightgrain")); while(!mp.game.streaming.hasModelLoaded(mp.game.joaat("freightgrain"))) mp.game.wait(0); if(!mp.game.streaming.hasModelLoaded(mp.game.joaat("freightcont1"))) mp.game.streaming.requestModel(mp.game.joaat("freightcont1")); while(!mp.game.streaming.hasModelLoaded(mp.game.joaat("freightcont1"))) mp.game.wait(0); if(!mp.game.streaming.hasModelLoaded(mp.game.joaat("freightcont2"))) mp.game.streaming.requestModel(mp.game.joaat("freightcont2")); while(!mp.game.streaming.hasModelLoaded(mp.game.joaat("freightcont2"))) mp.game.wait(0); if(!mp.game.streaming.hasModelLoaded(mp.game.joaat("freighttrailer"))) mp.game.streaming.requestModel(mp.game.joaat("freighttrailer")); while(!mp.game.streaming.hasModelLoaded(mp.game.joaat("freighttrailer"))) mp.game.wait(0); } if(commandName === "trainSpeed") { const speed = 5.0; mp.game.invoke('0xAA0BC91BE0B796E3', train, speed); mp.game.invoke('0x16469284DB8C62B5', train, speed); } }); Result:
Hanvod Posted August 28, 2018 Posted August 28, 2018 That code works with very low speed, but nothing happens if it greater that something near 3.0 https://streamable.com/mi505 if(commandName === "trainSpeed") { mp.game.invoke('0xAA0BC91BE0B796E3', train, 1.5); mp.game.invoke('0x16469284DB8C62B5', train, 1.5); } Value -0.25 makes it slowly go backwards
Hanvod Posted August 28, 2018 Posted August 28, 2018 (edited) values like 10.0 does nothing, value -1000 crashes the game. But I got this funny video, I dont know I managed to get this. https://streamable.com/1n1uz https://streamable.com/i4bak Edited August 28, 2018 by Hanvod
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now