How to get offset from vehicle?
#1

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
Reply
#2

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).
Reply
#3

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;

Reply
#4

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


Forum Jump:


Users browsing this thread: 1 Guest(s)