Get player offset from a vehicle
#1

So i want to know if there is a function that get the player offset when its inside a vehicle.

I tried:
Код:
GetPlayerPos(playerid, x, y, z);
GetVehiclePos(GetPlayerVehicleID(playerid), vx, vy, vz);
offsetx = x - vx;
offsety = y - vy;
offsetz = z - vz;
But doesnt work cause when the player is inside a car both coordinates are the same.


And im doing this to take the perfect position to put the object (to attach the camera) that is on player's head.

cause when i attach the object to the player, when driving, the car bugs, like a earthquake.
Reply
#2

Try fiddling around with the function GetVehicleModelInfo.
Reply
#3

I've made a function like this before. You can do it like you did before, and it should return their position. You can also try attaching an object and doing this:

pawn Код:
stock GetObjectOffset(objectid, vehicleid, &Float: X, &Float: Y, &Float: Z)
{
new Float: pos[3], vpos[3];
GetObjectPos(objectid, pos[0], pos[1], pos[2]);
GetVehiclePos(vehicleid, vpos[0], vpos[1], vpos[2]);
new calcpos[3];
calcpos[0] = pos[0]-vpos[0];
calcpos[1] = pos[1]-vpos[1];
calcpos[2] = pos[2]-vpos[2];
X = calcpos[0];
Y = calcpos[1];
Z = calcpos[2];
return 1;
}
Kinda like this:
https://sampforum.blast.hk/showthread.php?tid=541980

which i made a while ago
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)