SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 28/10/2019, 03:36 PM   #1
binnyl
Huge Clucker
 
Join Date: Aug 2017
Posts: 284
Reputation: 6
Default How to stop a train?



I wanna make train driver job, but i couldn't stop the train when player got on station

How to?

I tried:
Code:
            SetTimerEx("trainplanestoptimer", 30000, false, "i", playerid);
            TogglePlayerControllable(playerid, 0);
            SendClientMessage(playerid, COLOR_LIGHTRED, "Wait 30 seconds at that point to wait for passengers.");
Code:
forward trainplanestoptimer(playerid); public trainplanestoptimer(playerid) {
    TogglePlayerControllable(playerid, 1);
    SendClientMessage(playerid, COLOR_LIGHTBLUE, "GO GO GO!");
}
But the train doesn't stop when player enter on checkpoint, it still going, with less speed, i need to stop the train in the time to others player on station can get up on it

I'm creating the train on this:
Code:
VehicleInfo[vehid][vID] = AddStaticVehicleEx(VehicleInfo[vehid][vModel],VehicleInfo[vehid][vParkX], VehicleInfo[vehid][vParkY], VehicleInfo[vehid][vParkZ], VehicleInfo[vehid][vParkR], cor1,cor2,0);
binnyl is offline   Reply With Quote
Old 29/10/2019, 01:28 AM   #2
binnyl
Huge Clucker
 
Join Date: Aug 2017
Posts: 284
Reputation: 6
Default Re: How to stop a train?

Quote:
Originally Posted by Vizi10 View Post
Freeze the driver.
What?
That is exactly what i tried on the code i posted...
Ins't?


Code:
            SetTimerEx("trainplanestoptimer", 30000, false, "i", playerid);
            TogglePlayerControllable(playerid, 0);
            SendClientMessage(playerid, COLOR_LIGHTRED, "Wait 30 seconds at that point to wait for passengers.");

Code:
forward trainplanestoptimer(playerid); public trainplanestoptimer(playerid) {
    TogglePlayerControllable(playerid, 1);
    SendClientMessage(playerid, COLOR_LIGHTBLUE, "GO GO GO!");
}
binnyl is offline   Reply With Quote
Old 29/10/2019, 01:30 AM   #3
ImNext
Big Clucker
 
ImNext's Avatar
 
Join Date: Jul 2018
Posts: 56
Reputation: 0
Default Re: How to stop a train?

Try...

https://wiki.sa-mp.com/wiki/SetVehicleVelocity

Use this function to "freeze" the train.
ImNext is offline   Reply With Quote
Old 29/10/2019, 07:02 AM   #4
xRadical3
Huge Clucker
 
xRadical3's Avatar
 
Join Date: May 2017
Location: Iran
Posts: 448
Reputation: 13
Default Re: How to stop a train?

@binnyl use this method:
Destroy the train and spawn it in last checkpoint position and use the PutPlayerInVehicle.
I not has any idea but This method should work

Quote:
Originally Posted by ImNext View Post
Try...

https://wiki.sa-mp.com/wiki/SetVehicleVelocity

Use this function to "freeze" the train.
Wiki: This function has no affect on un-occupied vehicles and does not affect trains.
xRadical3 is offline   Reply With Quote
Old 29/10/2019, 02:13 PM   #5
Mugala
High-roller
 
Mugala's Avatar
 
Join Date: Nov 2012
Location: Georgia, Tbilisi
Posts: 1,162
Reputation: 73
Default Re: How to stop a train?

SetVehicleVelocity doesn't works for trains, so you just have to re-create a train as Vizi said, just use GetVehiclePos to get the position of current train and ZAngle to set a correct direction.
__________________
Coding in 8 languages including Pawn, C#, C++ and SQL.
Available for hiring.

If you have a coding question or need an assistance in a code, just PM me.
If you want me to create something for you, here is a Discord Mugala#5651

Currently helping Community members in a coding.
Mugala is offline   Reply With Quote
Old 02/11/2019, 12:58 AM   #6
binnyl
Huge Clucker
 
Join Date: Aug 2017
Posts: 284
Reputation: 6
Default Re: How to stop a train?

That is it, i rep u both, ty!
@vizi and @mugala
binnyl is offline   Reply With Quote
Old 02/11/2019, 01:00 AM   #7
IllidanS4
Huge Clucker
 
IllidanS4's Avatar
 
Join Date: Feb 2013
Posts: 200
Reputation: 275
Default Re: How to stop a train?

No need to recreate it, SetVehicleToRespawn is sufficient.
IllidanS4 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
the train itself Jimmi Scripting Help 1 27/08/2015 04:59 AM
Attach train trailer to train? jeremy8810 Server Support 3 29/07/2012 09:48 PM
stop train dud Help Archive 13 21/06/2011 07:41 AM
Train Puzi Help Archive 6 07/03/2010 11:44 PM
Can you map out train tracks and put a train on them?. [mad]MLK Help Archive 7 18/10/2009 05:40 PM


All times are GMT. The time now is 04:22 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.