Stopping a Train
#1

How can i get a train to stop when it enters a checkpoint, TogglePlayerControllable(0); Dosen't stop a train and i think SetVehicleVelocity dosen't work on trains.

Basically what i'm trying to do is make a train driving job and you stop at each train stop now i want the train to stop when it enters the checkpoint and not move anymore till they can go to the next stop.

Everything i have tried dosen't seem to stop the train toggling player controlable the train keeps moving but you can't control it.

I want the train to stop instantly intill they're free to move again.
Reply
#2

Is the train a bot or a player?

For players, SetVehicleVelocity is your best bet (you "think", did you try it?), maybe combine it with SetPlayerVelocity to make sure. These will only stop it so you'll need to freeze the player as you did originally to stop them starting it again.

For bots, you'll just have to make a stop recording for each checkpoint and play a go recording when they go to the next stop.
Reply
#3

Quote:
Originally Posted by Simon
Is the train a bot or a player?

For players, SetVehicleVelocity is your best bet (you "think", did you try it?), maybe combine it with SetPlayerVelocity to make sure. These will only stop it so you'll need to freeze the player as you did originally to stop them starting it again.

For bots, you'll just have to make a stop recording for each checkpoint and play a go recording when they go to the next stop.
I thought SetVehicleVelocity didn't work with trains, I could try setplayerclocity
Reply
#4

Sorry for the bump, but setvehiclevlocity won't work with the train how esle can i stop a train?
Reply
#5

setplayerpos setvehiclepos maybe?

else if its a bot just use pauserecordingplayback under if isplayerinrangeofpoint .
isplayerinrangeofpoint works in an npc script if you use it correctly
Reply
#6

It's not an npc it's a player driving the train, if i do setplayerpos wouldn't the train keep moving after it's been set?
Reply
#7

You could try Seif's vehicle functions It has something like FreezeVehicle
Reply
#8

Quote:
Originally Posted by Fj0rtizFredde
You could try Seif's vehicle functions It has something like FreezeVehicle
It's not stopping the train, Anyone esle have any other ideas?
Reply
#9

GetPlayerPos then SetPlayerPos? try that..
Reply
#10

i presume that you #include(d) ZCMD, if so, then here you go - a simple ZCommand for stopping a train. it looks ugly, but nevertheless it works
btw, the trick is, to °1st: set the vehicles velocity to zero, and °2nd: apply its recent position again. the rest is just decoration to make it look better (skip a frame? does it really work? hm...)
Код:
CMD:StopTrainOrTram(playerid,cmdtext[])
{
	new Float:X,Float:Y,Float:Z,Float:VX,Float:VY,Float:VZ;
	new Veh=GetPlayerVehicleID(playerid);
	GetVehicleVelocity(Veh,VX,VY,VZ);
	GetVehiclePos(Veh,X,Y,Z);
	SetVehicleVelocity(Veh,0,0,0);
	SetVehiclePos(Veh,X+VX,Y+VY,Z+VZ);
	return 1;
}
,,,
', regards
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)