PDA

View Full Version : I look for help for PutPlayerInVehicle.


Join7
15/11/2011, 01:05 PM
I look for help for PutPlayerInVehicle.
I want a command when use /tramenter, to enter into tram
AddStaticVehicle(449,1944.9480,-1953.7500,14.2082,270.0000,36,0);
I also want command /tramexit, with which I leave tram

Kostas'
15/11/2011, 01:17 PM
new tram;

public OnGameModeInit( )
{
tram = AddStaticVehicle(449,1944.9480,-1953.7500,14.2082,270.0000,36,0);
//More
return 1;
}

//Commands
CMD:tramenter(playerid, params[])
{
PutPlayerInVehicle(playerid,tram,0);
return 1;
}

Elka_Blazer
15/11/2011, 01:19 PM
On the top of your script
new TramCar;

Under OnGameModeInIt ( or OnFilterScriptInIt if its a filterscript )

TramCar = AddStaticVehicle(449,1944.9480,-1953.7500,14.2082,270.0000,36,0);

The commands :


if(strcmp(cmdtext,"/tramenter",true) == 0)
{
PutPlayerInVehicle(playerid,TramCar);
return 1;
}

if(strcmp(cmdtext,"/tramexit",true) == 0)
{
if(IsPlayerInAnyVehicle(playerid))
{
if(GetPlayerVehicleID(playerid) == TramCar)
{
RemovePlayerFromVehicle(playerid);
}
}
return 1;
}

Kostas'
15/11/2011, 01:22 PM
On the top of your script
new TramCar;

Under OnGameModeInIt ( or OnFilterScriptInIt if its a filterscript )

TramCar = AddStaticVehicle(449,1944.9480,-1953.7500,14.2082,270.0000,36,0);

The commands :


if(strcmp(cmdtext,"/tramenter",true) == 0)
{
PutPlayerInVehicle(playerid,TramCar);
return 1;
}

if(strcmp(cmdtext,"/tramexit",true) == 0)
{
if(IsPlayerInAnyVehicle(playerid))
{
if(GetPlayerVehicleID(playerid) == TramCar)
{
RemovePlayerFromVehicle(playerid);
}
}
return 1;
}


You wrote

PutPlayerInVehicle(playerid,TramCar);

You didn't add the seatid

Elka_Blazer
15/11/2011, 01:27 PM
Yea srry ....

Join7
15/11/2011, 01:45 PM
As I get off the tram, the camera remains in it

Kostas'
15/11/2011, 01:50 PM
Destroy the tram then


CMD:tramexit(playerid, params[])
{
if(IsPlayerInAnyVehicle(playerid)) {
if(GetPlayerVehicleID(playerid) == tram) {
RemovePlayerFromVehicle(playerid);
DestroyVehicle(tram);
}
}
return 1;
}

Join7
15/11/2011, 02:14 PM
Not DestroyVehicle, because this Destroy the tram

MP2
15/11/2011, 02:18 PM
Use SetCameraBehindPlayer.

Join7
15/11/2011, 02:25 PM
The aim is to take me off the tram. Like /slap
SetCameraBehindPlayer with this command gives me the camera high, while the tram stops, go to my player

Kostas'
15/11/2011, 02:30 PM
If you respawn the tram, it would stop have the camera on the tram

Join7
15/11/2011, 02:32 PM
There must be a way to be as /slap. To throw me out of the tram

Smally
15/11/2011, 02:37 PM
CMD:tramexit(playerid, params[])
{
if(IsPlayerInAnyVehicle(playerid)) {
if(GetPlayerVehicleID(playerid) == tram) {
RemovePlayerFromVehicle(playerid);
SetCameraBehindPlayer(playerid);
}
}
return 1;
}

Try that

Join7
15/11/2011, 02:43 PM
But as with SetCameraBehindPlayer, when write /tramexit camera gives me a view from above

Smally
15/11/2011, 02:46 PM
Ok try changing it to SetCameraBehindPlayer(i); that

Kostas'
15/11/2011, 03:02 PM
Try this

CMD:tramexit(playerid, params[])
{
if(IsPlayerInAnyVehicle(playerid)) {
if(GetPlayerVehicleID(playerid) == tram) {
RemovePlayerFromVehicle(playerid);
for(new i = tram; i <= MAX_VEHICLES; i++) {
SetVehicleToRespawn(i);
}
}
}
return 1;
}

KosmasRego
15/11/2011, 03:05 PM
Try doing as Kostas' said to destroy the tram when exiting.

Join7
15/11/2011, 03:16 PM
I do not want to respawn

Kostas'
15/11/2011, 03:29 PM
Oh! I can't think something else right now.
However, the tram will respawn, not destroy

Join7
15/11/2011, 05:01 PM
I fixed it. Only by clicking F / ENTER, this does not work with the camera.
How to Fix It?