SA-MP Forums Archive
Teleport Vehicle to Vehicle Face Angle - 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)
+--- Thread: Teleport Vehicle to Vehicle Face Angle (/showthread.php?tid=624424)



Teleport Vehicle to Vehicle Face Angle - Hayden_Almeida - 16.12.2016

I am trying to do this:

Teleport one vehicle to another vehicle's back. Whatever the angle i am looking at.

Example:
If i am im pos (inside vehicle, state driver):
Код:
0.0 , 0.0 , 0.0
And i am looking at NORH (0.0)
The second vehicle will be teleported to:
Код:
0.0 , -1.0 , 0.0
Because when i move to NORTH, the Y position is changing.
So my logic at this point is: Get the BOTH vehicle positions and the ZAngle of the FIRST vehicle (i am in it). And now??


Re: Teleport Vehicle to Vehicle Face Angle - AbyssMorgan - 16.12.2016

For example, if you want to set the vehicle behind the vehicle.
PHP код:
new Float:tx,Float:ty,Float:tz,Float:angle;
GetVehicleOrientationPos(vehicleid,o_back,10.0,tx,ty,tz);
SetVehiclePos(new_vehicleid,tx,ty,tz);
GetVehicleZAngle(vehicleid,angle);
SetVehicleZAngle(new_vehicleid,angle); 
3DTryg.inc:
https://sampforum.blast.hk/showthread.php?tid=591010


Re: Teleport Vehicle to Vehicle Face Angle - Hayden_Almeida - 16.12.2016

Quote:
Originally Posted by AbyssMorgan
Посмотреть сообщение
For example, if you want to set the vehicle behind the vehicle.
PHP код:
new Float:tx,Float:ty,Float:tz,Float:angle;
GetVehicleOrientationPos(vehicleid,o_back,10.0,tx,ty,tz);
SetVehiclePos(new_vehicleid,tx,ty,tz);
GetVehicleZAngle(vehicleid,angle);
SetVehicleZAngle(new_vehicleid,angle); 
3DTryg.inc:
https://sampforum.blast.hk/showthread.php?tid=591010
GetVehicleOrientationPos ?? This function exists??


Re: Teleport Vehicle to Vehicle Face Angle - AbyssMorgan - 16.12.2016

Quote:
Originally Posted by Hayden_Almeida
Посмотреть сообщение
GetVehicleOrientationPos ?? This function exists??
Yes, in 3DTryg.inc


Re: Teleport Vehicle to Vehicle Face Angle - Swedky - 16.12.2016

PHP код:
new Float:fXFloat:fYFloat:fZFloat:angle;
GetVehiclePos(vehicleidfXfYfZ);
GetVehicleZAngle(vehicleidangle);
SetVehiclePos(vehicle2fX + (dist floatsin(-angledegrees)), fY + (dist floatcos(-angledegrees)), fZ); 
Change "dist" to the distance where you want to put "vehicle2". Positive values will put it in front, negative will put it in back.


Re: Teleport Vehicle to Vehicle Face Angle - Hayden_Almeida - 16.12.2016

Quote:
Originally Posted by Swedky
Посмотреть сообщение
PHP код:
new Float:fXFloat:fYFloat:fZFloat:angle;
GetVehiclePos(vehicleidfXfYfZ);
GetVehicleZAngle(vehicleidangle);
SetVehiclePos(vehicle2fX + (dist floatsin(-angledegrees)), fY + (dist floatcos(-angledegrees)), fZ); 
Change "dist" to the distance where you want to put "vehicle2". Positive values will put it in front, negative will put it in back.
Does not work so well.
I am trying to detach the Trailer from truck, but if i only use the Function "DetachTrailerFromVehicle" it not sync sometime with other players. Know how to solve it?
With some tests i came to use teleport trailer from 2 meters of the truck behind it.