PDA

View Full Version : Teleporting with a car


KingyKings
07/12/2013, 03:39 PM
So i have looked at quite a lot of tutorials but still can't get it to work?

Here is the code:



if(strcmp(cmd, "/lsair", true) == 0) {

if(InDM[playerid] == 1)
{
SendClientMessage(playerid, COLOR_RED, "Please type /leavedm first!");
return 1;
}
else
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new getv = GetPlayerVehicleID(playerid);
SetVehiclePos(getv,1643.1212,-2419.4958,13.2818);
SetPlayerPos(playerid,1643.1212,-2419.4958,13.2818);
PutPlayerInVehicle(playerid,getv,0);
return 1;
}
else
{
SetPlayerPos(playerid, 1648.6609,-2414.7664,13.5547);
return 1;
}

}
}

It compiles fine but in game it doesn't work?

It is suppost to teleport WITH the car however it doesn't.

Any help appreciated!

Konstantinos
07/12/2013, 03:44 PM
if(!strcmp(cmd, "/lsair", true))
{
if(InDM[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "Please type /leavedm first!");
switch(GetPlayerState(playerid))
{
case PLAYER_STATE_ONFOOT: SetPlayerPos(playerid, 1648.6609,-2414.7664,13.5547);
case PLAYER_STATE_DRIVER: SetVehiclePos(GetPlayerVehicleID(playerid),1643.12 12,-2419.4958,13.2818);
case PLAYER_STATE_PASSENGER:
{
RemovePlayerFromVehicle(playerid);
SetPlayerPos(playerid, 1648.6609,-2414.7664,13.5547);
}
}
return 1;
}

KingyKings
07/12/2013, 03:50 PM
Thankyou so much for the help mate but it still appears not to be working O.o

I get in a vehicle types /lsair and it just teleports me without the car O>o

Audi_Quattrix
07/12/2013, 04:35 PM
try this:
if(!strcmp(cmd, "/lsair", true))
{
if(InDM[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "Please type /leavedm first!");
switch(GetPlayerState(playerid))
{
case PLAYER_STATE_ONFOOT: SetPlayerPos(playerid, 1648.6609,-2414.7664,13.5547);
case PLAYER_STATE_DRIVER:
{
new veh = GetPlayerVehicleID(playerid);
SetVehiclePos(veh,1643.1212,-2419.4958,13.2818);
SetPlayerPos(playerid,1643.1212,-2419.4958,13.2818);
PutPlayerInVehicle(playerid,veh,0);
}
case PLAYER_STATE_PASSENGER:
{
RemovePlayerFromVehicle(playerid);
SetPlayerPos(playerid, 1648.6609,-2414.7664,13.5547);
}
}
return 1;
}

KingyKings
07/12/2013, 04:42 PM
That works, thankyou so much!

Audi_Quattrix
07/12/2013, 04:42 PM
No problem :D