SA-MP Forums Archive
Vehicle's petrolcap pos - 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: Vehicle's petrolcap pos (/showthread.php?tid=647585)



Vehicle's petrolcap pos - zsoolt997 - 07.01.2018

Is it possibly to get any vehicle's petrolcap positions?
I have found few scripts that can make it, but they aren't working on unoccupied vehicles because they use GetVehicleRotationQuat function which is give fake info if the vehicle updated by a player and there is no one in it.

Thanks in advance.


Re: Vehicle's petrolcap pos - Infra - 07.01.2018

This might work:

pawn Код:
new Float: modelX, Float: modelY, Float: modelZ,
    Float: X, Float: Y, Float: Z, Float: R;

GetVehiclePos(vehicleid, X, Y, Z);
GetVehicleZAngle(vehicleid, R);
GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_PETROLCAP, modelX, modelY, modelZ);
                   
Z += modelZ;

X += (modelY * floatsin(-R, degrees));
Y += (modelY * floatcos(-R, degrees));

R += 270.0;
X += (modelX * floatsin(-R, degrees));
Y += (modelX * floatcos(-R, degrees));
R -= 270.0;
                   
if(IsPlayerInRangeOfPoint(playerid, 1.0, X, Y, Z))
{
    // Player is at (or atleast very close to) the petrolcap
}



Re: Vehicle's petrolcap pos - zsoolt997 - 07.01.2018

Quote:
Originally Posted by Infra
Посмотреть сообщение
This might work:

pawn Код:
new Float: modelX, Float: modelY, Float: modelZ,
    Float: X, Float: Y, Float: Z, Float: R;

GetVehiclePos(vehicleid, X, Y, Z);
GetVehicleZAngle(vehicleid, R);
GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_PETROLCAP, modelX, modelY, modelZ);
                   
Z += modelZ;

X += (modelY * floatsin(-R, degrees));
Y += (modelY * floatcos(-R, degrees));

R += 270.0;
X += (modelX * floatsin(-R, degrees));
Y += (modelX * floatcos(-R, degrees));
R -= 270.0;
                   
if(IsPlayerInRangeOfPoint(playerid, 1.0, X, Y, Z))
{
    // Player is at (or atleast very close to) the petrolcap
}
Thank you very much, this is working!