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(playerid, vehiclemodel, color1, color2)
{
    new 
Float:x,Float:y,Float:z;
    new 
Float:facing;
    new 
Float:distance;
    
GetPlayerPos(playerid, x, y, z);
    
GetPlayerFacingAngle(playerid, facing);
    new 
Float:size_x,Float:size_y,Float:size_z;
    
GetVehicleModelInfo(vehiclemodel, VEHICLE_MODEL_INFO_SIZE, size_x, size_y, size_z);
    
    
distance = size_x + 0.5;
      
x += (distance * floatsin(-facing, degrees));
    
y += (distance * floatcos(-facing, degrees));
    
facing += 90.0;
    if(
facing > 360.0) facing -= 360.0;
    return 
CreateVehicle(vehiclemodel, x, y, z + (size_z * 0.25), facing, color1, color2, -1);
} 
example:

PHP код:
CMD:v(playerid, params[])
{
    
SpawnVehicle_InfrontOfPlayer(playerid, strval(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)