Jump to content
RAGE Multiplayer Community

createMissionTrain crash


Recommended Posts

  • Replies 33
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

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.g

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);
	}
});

 

Link to post
Share on other sites

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?

Link to post
Share on other sites

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"));

 

  • Like 1
Link to post
Share on other sites

 

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 by Hanvod
Link to post
Share on other sites
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 by Hanvod
Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.


×
×
  • Create New...