GetXYZInFrontOfVehicle ?
#1

How i can do this? Thank you for response.
Reply
#2

Here is the code for GetXYInFrontOfVehicle()

pawn Код:
GetXYInFrontOfVehicle(playerid, &Float:x, &Float:y, Float:distance)
{
    new Float:a;
    GetVehiclePos(playerid, x, y, a);
    GetVehicleZAngle(playerid, a);
    x += (distance * floatsin(-a, degrees));
    y += (distance * floatcos(-a, degrees));
}
Reply
#3

Quote:
Originally Posted by JacobEdwards
Посмотреть сообщение
Here is the code for GetXYInFrontOfVehicle()

pawn Код:
GetXYInFrontOfVehicle(playerid, &Float:x, &Float:y, Float:distance)
{
    new Float:a;
    GetVehiclePos(playerid, x, y, a);
    GetVehicleZAngle(playerid, a);
    x += (distance * floatsin(-a, degrees));
    y += (distance * floatcos(-a, degrees));
}
Yeah, but i need Z-axis.
I have this code: http://pastebin.com/uDz10QEQ
But this doesnt' work properly, the checkpoint don't appears sometimes.
Sorry for my bad english
Reply
#4

You need the z (height) and that can be found by GetVehiclePos function. I added + 1 to the current height just to prevent it to be underground. If it's over the ground though, you can remove it.

pawn Код:
GetXYZInFrontOfVehicle(vehicleid, &Float:x, &Float:y, &Float:z, Float:distance)
{
    new Float:a;
    GetVehiclePos(playerid, x, y, z);
    GetVehicleZAngle(playerid, a);
    x += (distance * floatsin(-a, degrees));
    y += (distance * floatcos(-a, degrees));
    z += 1.0;
}
You don't need the rotations of the vehicle.
Reply
#5

Okay, thank you.
But i have a problem, when i enter in a car and i rotate it, the checkpoint appears in another position.
Reply
#6

Do you create the checkpoint after entering the car or before?
Reply
#7

** Sorry for doublepost **
Screens:
http://gyazo.com/6602bab02a4ea2529a7fff8a2f61be20
http://gyazo.com/8229ebde61ad210b64bbbe0cf6c3845b
http://gyazo.com/80b918f71500ba026de660e2b8c983c2
EDIT: I create the checkpoint when im in a house (interior).
Reply
#8

So you're not in the car. I'm not sure but I think there's a bug with SetVehicleZAngle function and it won't set the angle if the vehicle is not occupied. So it might return the previous angle and that's why it doesn't create it in front of it.
Reply
#9

Quote:
Originally Posted by JacobEdwards
Посмотреть сообщение
Here is the code for GetXYInFrontOfVehicle()

pawn Код:
GetXYInFrontOfVehicle(playerid, &Float:x, &Float:y, Float:distance)
{
    new Float:a;
    GetVehiclePos(playerid, x, y, a);
    GetVehicleZAngle(playerid, a);
    x += (distance * floatsin(-a, degrees));
    y += (distance * floatcos(-a, degrees));
}
Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
So you're not in the car. I'm not sure but I think there's a bug with SetVehicleZAngle function and it won't set the angle if the vehicle is not occupied. So it might return the previous angle and that's why it doesn't create it in front of it.
So? I can't? I must create the checkpoint behind the car but the coord are wrong. I don't know how to do...
Reply
#10

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
You need the z (height) and that can be found by GetVehiclePos function. I added + 1 to the current height just to prevent it to be underground. If it's over the ground though, you can remove it.

pawn Код:
GetXYZInFrontOfVehicle(vehicleid, &Float:x, &Float:y, &Float:z, Float:distance)
{
    new Float:a;
    GetVehiclePos(playerid, x, y, z);
    GetVehicleZAngle(playerid, a);
    x += (distance * floatsin(-a, degrees));
    y += (distance * floatcos(-a, degrees));
    z += 1.0;
}
You don't need the rotations of the vehicle.
You serious? All you've done is adding +1 to Z coord, that is not correct way to do it xD
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)