How to teleport player to train as passenger, and he wont be able to exit?
#1

How I can make that? NPC train driver come to station, player will get teleported to train as passenger and he wont be able to exit this train? Thx
Reply
#2

Say we have a variable called "new npctrain" which = the vehicle ID of the train, the NPC is using...

When the train comes in to the station now, you can teleport the player into like that:

Код:
PutPlayerInVehicle(playerid, npctrain, 1);
To prevent him from leaving the train, you can freeze the player
Код:
TogglePlayerControllable(playerid, 0);
To get sure, that there aren't players in the same seat (not sure if that would cause errors, you can use something like that) [NOT TESTET!!]

at the top of your script:
Код:
#define MAX_TRAIN_SEATS 20 //CHANGE THAT TO YOUR CUSTOM WISHES - THE MAX AMOUNTS OF SEATS THAT YOU TRAIN SHOULD HAVE
and then at the function or callback that says you whether the train entered the station:

Код:
new blocked = 0;
for(new n=1; n<=MAX_TRAIN_SEATS; n++)
{
	blocked = 0;
	for(new i=0; i<GetMaxPlayers(); i++)
	{
	    if(IsPlayerConnected(i) && GetPlayerVehicleID(i) == npctrain)
	    {
	        if(GetVehicleSeat(i) == n)
	        {
	            blocked = 1;
			}
		}
	}
	if(blocked == 0)
	{
	    PutPlayerInVehicle(playerid, npctrain, n);
		TogglePlayerControllable(playerid, 0);
	}
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)