SA-MP Forums Archive
How to get offset from vehicle? - 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: How to get offset from vehicle? (/showthread.php?tid=657206)



How to get offset from vehicle? - R3SpaWn0 - 03.08.2018

Hi..the problem is that when i join in server, me and the car are in the same coords, how can i get the player or car little offset at the X or Y? Thanks..

This is the problem
https://imgur.com/a/0QJfJGU


Re: How to get offset from vehicle? - GRiMMREAPER - 03.08.2018

You don't need to create another thread as I would've replied here.

If you want to add an offset, get the x coordinate of the player's spawn point and add/subtract a number to it (like +3 or -3).


Re: How to get offset from vehicle? - Lokii - 03.08.2018

You can use this function from vspawner:

PHP код:
SpawnVehicle_InfrontOfPlayer(playeridvehiclemodelcolor1color2)
{
    new 
Float:x,Float:y,Float:z;
    new 
Float:facing;
    new 
Float:distance;
    
GetPlayerPos(playeridxyz);
    
GetPlayerFacingAngle(playeridfacing);
    new 
Float:size_x,Float:size_y,Float:size_z;
    
GetVehicleModelInfo(vehiclemodelVEHICLE_MODEL_INFO_SIZEsize_xsize_ysize_z);
    
    
distance size_x 0.5;
      
+= (distance floatsin(-facingdegrees));
    
+= (distance floatcos(-facingdegrees));
    
facing += 90.0;
    if(
facing 360.0facing -= 360.0;
    return 
CreateVehicle(vehiclemodelxy+ (size_z 0.25), facingcolor1color2, -1);

example:

PHP код:
CMD:v(playeridparams[])
{
    
SpawnVehicle_InfrontOfPlayer(playeridstrval(params), -1, -1);
    return 
1;




Re: How to get offset from vehicle? - R3SpaWn0 - 03.08.2018

Thank you all, i will try it now ґ!!