SA-MP Forums Archive
Stopping a Train - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Stopping a Train (/showthread.php?tid=152622)



Stopping a Train - ihatetn931 - 05.06.2010

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.


Re: Stopping a Train - Simon - 05.06.2010

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.


Re: Stopping a Train - ihatetn931 - 05.06.2010

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


Re: Stopping a Train - ihatetn931 - 05.06.2010

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


Re: Stopping a Train - boelie - 05.06.2010

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


Re: Stopping a Train - ihatetn931 - 05.06.2010

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?


Re: Stopping a Train - Fj0rtizFredde - 05.06.2010

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


Re: Stopping a Train - ihatetn931 - 06.06.2010

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?


Re: Stopping a Train - Antonio [G-RP] - 06.06.2010

GetPlayerPos then SetPlayerPos? try that..


Re: Stopping a Train - Babul - 06.06.2010

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