Get player offset from a 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: Get player offset from a vehicle (
/showthread.php?tid=548581)
Get player offset from a vehicle -
Rodney Francalim - 30.11.2014
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.
Re: Get player offset from a vehicle -
Threshold - 01.12.2014
Try fiddling around with the function
GetVehicleModelInfo.
Re: Get player offset from a vehicle -
Abagail - 01.12.2014
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