SA-MP Forums Archive
How to teleport car with trailer? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to teleport car with trailer? (/showthread.php?tid=176163)



How to teleport car with trailer? - whitedragon - 12.09.2010

Topic title says all


Re: How to teleport car with trailer? - LarzI - 12.09.2010

SetVehiclePos
AttachTrailerToVehicle

?


Re: How to teleport car with trailer? - whitedragon - 12.09.2010

Nope that not help


Re: How to teleport car with trailer? - LarzI - 12.09.2010

How can that not help? It is possible.


Re: How to teleport car with trailer? - whitedragon - 12.09.2010

like the AttachTrailerToVehicle is not teleport the trailer to vehicle


Re: How to teleport car with trailer? - LarzI - 12.09.2010

You have to set the trailers position too then.


Re: How to teleport car with trailer? - LarzI - 12.09.2010

You could make a custom function

pawn Код:
stock SetVehicleAndTrailerPos(vehicleid, trailerid, Float:posx, Float:posy, Float:posz)
{
    new Float:bx, Float:by;
    GetVehicleTrailer( vehicleid );
    SetVehiclePos( vehicleid, posx, posy, posz );
    GetXYBehindVehicle( vehicleid, bx, by, 5.0 );
    SetVehiclePos( trailerid, bx, by, posz );
    AttachTrailerToVehicle( trailerid, vehicleid );
    return true;
}
pawn Код:
stock GetXYBehindOfVehicle(vehicleid, &Float:x, &Float:y, Float:distance)
{
    new
        Float:a;
    GetVehiclePos( vehicleid, x, y, a );
    GetVehicleZAngle( vehicleid, a );
    x += ( distance * floatsin( -a+180, degrees ));
    y += ( distance * floatcos( -a+180, degrees ));
}
Can't garantuee that it will work 100%, or work at all.


Re: How to teleport car with trailer? - Voldemort - 12.09.2010

I have also tried with SetVehiclePos ( trailer ), but trailer always stays at old pos


Re: How to teleport car with trailer? - CrucixTM - 12.09.2010

Quote:
Originally Posted by LarzI
Посмотреть сообщение
You could make a custom function

pawn Код:
stock SetVehicleAndTrailerPos(vehicleid, trailerid, Float:posx, Float:posy, Float:posz)
{
    new Float:bx, Float:by;
    GetVehicleTrailer( vehicleid );
    SetVehiclePos( vehicleid, posx, posy, posz );
    GetXYBehindVehicle( vehicleid, bx, by, 5.0 );
    SetVehiclePos( trailerid, bx, by, posz );
    AttachTrailerToVehicle( trailerid, vehicleid );
    return true;
}
pawn Код:
stock GetXYBehindOfVehicle(vehicleid, &Float:x, &Float:y, Float:distance)
{
    new
        Float:a;
    GetVehiclePos( vehicleid, x, y, a );
    GetVehicleZAngle( vehicleid, a );
    x += ( distance * floatsin( -a+180, degrees ));
    y += ( distance * floatcos( -a+180, degrees ));
}
Can't garantuee that it will work 100%, or work at all.
Stocks are supposed to return a value, or am I wrong?


Re: How to teleport car with trailer? - LarzI - 12.09.2010

Not necesarly.