Angles and advanced mathematics regarding fuelcap positions
#1

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!
Reply
#2

I found a tiny mistake - you're passing the model as a parameter when you should be passing the vehicle's ID.
Reply
#3

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!
Reply


Forum Jump:


Users browsing this thread: