Teleport to Red Marker w/ Vehicle
#1

This is the teleport to marker simple script but without vehicle.

Quote:

public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
{
SetPlayerPos(playerid, fX, fY, fZ);
return 1;
}

Im looking for a teleport marker with vehicle this time.
Reply
#2

Like this:
pawn Код:
public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        SetVehiclePos(playerid, fX, fY, fZ);
    }
    else
    {
        SetPlayerPos(playerid, fX, fY, fZ);
    }
    return 1;
}
If the player is in a vehicle, the vehicle gets teleported.
Otherwise it's just the player.
Reply
#3

Use this, this is correct.

pawn Код:
public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
{
new Babatz = GetPlayerVehicleID(playerid);
if(!Babatz) SetPlayerPos(playerid, fX, fY, fZ);
else {new Batz = GetPlayerVehicleSeat(playerid);SetVehiclePos(Babatz,fX,fY,fZ);PutPlayerInVehicle(playerid,Babatz,Batz);}
return 1;
}
Reply
#4

Quote:
Originally Posted by Pangea
Посмотреть сообщение
Like this:
pawn Код:
public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        SetVehiclePos(playerid, fX, fY, fZ);
    }
    else
    {
        SetPlayerPos(playerid, fX, fY, fZ);
    }
    return 1;
}
If the player is in a vehicle, the vehicle gets teleported.
Otherwise it's just the player.
Player cant teleport but vehicle wont. still no changes at all. You know why?

No error after compiling.
Reply
#5

It's because he used SetVehiclePos(playerid, fX, fY, fZ);
Use this:

pawn Код:
public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
{
new Babatz = GetPlayerVehicleID(playerid);
if(!Babatz) SetPlayerPos(playerid, fX, fY, fZ);
else {new Batz = GetPlayerVehicleSeat(playerid);SetVehiclePos(Babatz,fX,fY,fZ);PutPlayerInVehicle(playerid,Babatz,Batz);}
return 1;
}
Reply
#6

Oh god, I failed a little hard there. My bad.
pawn Код:
public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        SetVehiclePos(vehicleid, fX, fY, fZ);
    }
    else
    {
        SetPlayerPos(playerid, fX, fY, fZ);
    }
    return 1;
}
Reply
#7

Quote:
Originally Posted by Grand_Micha
Посмотреть сообщение
Use this, this is correct.

pawn Код:
public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
{
new Babatz = GetPlayerVehicleID(playerid);
if(!Babatz) SetPlayerPos(playerid, fX, fY, fZ);
else {new Batz = GetPlayerVehicleSeat(playerid);SetVehiclePos(Babatz,fX,fY,fZ);PutPlayerInVehicle(playerid,Babatz,Batz);}
return 1;
}
thanks bro! works like a charm +rep. Do you know whats the differences of the other script given by pangea, and why it does not working but no errors at all?
Reply
#8

I forgot to get the id of the vehicle and teleport that vehicle.
Instead of that I took the ID of the player. xD

The second one I gave would do the trick.
Reply
#9

Quote:
Originally Posted by Pangea
Посмотреть сообщение
Oh god, I failed a little hard there. My bad.
pawn Код:
public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        SetVehiclePos(vehicleid, fX, fY, fZ);
    }
    else
    {
        SetPlayerPos(playerid, fX, fY, fZ);
    }
    return 1;
}
I see now haha. thanks man. +rep
Reply
#10

Yes. He used SetVehiclePos(playerid, fX, fY, fZ);
He probably meant: SetVehiclePos(GetPlayerVehicleID(playerid), fX, fY, fZ);

That would result in just your car being teleported, and you staying.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)