Angles and advanced mathematics regarding fuelcap positions - 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: Angles and advanced mathematics regarding fuelcap positions (
/showthread.php?tid=393228)
Angles and advanced mathematics regarding fuelcap positions -
Flyfishes - 17.11.2012
Hi! I'm trying to place a checkpoint at the location of a specific vehicle's fuel cap. The problem is that I'm not very got at advanced mathematics so I would need someones assistance now to help me out
I've found this function somewhere here on the SA-MP forums. (Credits to whoever made it). But it seems like it's not working for me when I put it into action.
pawn Код:
stock GetVehicleInfo(vehicleid, infotype, &Float:x, &Float:y, &Float:z, &Float:angle)
{
if(!IsVehicleValid(vehicleid)) return 0;
new Float:mX, Float:mY, Float:mZ;
GetVehicleModelInfo(GetVehicleModel(vehicleid), infotype, mX, mY, mZ);
z += mZ;
x += (mY * floatsin(-angle, degrees));
y += (mY * floatcos(-angle, degrees));
angle += 270.0;
x += (mX * floatsin(-angle, degrees));
y += (mX * floatcos(-angle, degrees));
angle -= 270.0;
return 1;
}
pawn Код:
new cID = GetClosestVehicle(playerid);
new Float: pos[4];
GetVehiclePos(cID, pos[0], pos[1], pos[2]);
GetVehicleZAngle(cID, pos[3]);
if(IsPointInDynamicArea(pVariables[i][pArea], pos[0], pos[1], pos[2]))
{
GetVehicleInfo(GetVehicleModel(cID), VEHICLE_MODEL_INFO_PETROLCAP, pos[0], pos[1], pos[2], pos[3]);
SetPlayerCheckpoint(playerid, pos[0], pos[1], pos[2], 0.5);
}
The checkpoint gets placed on the GetVehiclePos coords. Am I just stupid and did a small mistake or?
Thank you for your help!
Re: Angles and advanced mathematics regarding fuelcap positions -
Stylock - 17.11.2012
I found a tiny mistake - you're passing the model as a parameter when you should be passing the vehicle's ID.
Re: Angles and advanced mathematics regarding fuelcap positions -
Flyfishes - 17.11.2012
Quote:
Originally Posted by YJIET
I found a tiny mistake - you're passing the model as a parameter when you should be passing the vehicle's ID.
|
Thanks man, stupid me. It's working now!
Thanks!