15.09.2013, 23:11
I'm using MP2's function for checking if a player is near a vehicle's trunk. I've experimented on checking if the player is near the hood a couple of times but to no success. I'm not sure on what value to change, I tried subtracting the offset (didn't work) and also making the float values positive instead of negative.
Appreciate any help and if you could explain, that would be awesome!
Appreciate any help and if you could explain, that would be awesome!
pawn Код:
stock GetPosBehindVehicle(vehicleid, &Float:x, &Float:y, &Float:z, Float:offset=0.5)
{
new Float:vehicleSize[3], Float:vehiclePos[3];
GetVehiclePos(vehicleid, vehiclePos[0], vehiclePos[1], vehiclePos[2]);
GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_SIZE, vehicleSize[0], vehicleSize[1], vehicleSize[2]);
GetXYBehindVehicle(vehicleid, vehiclePos[0], vehiclePos[1], (vehicleSize[1]/2)+offset);
x = vehiclePos[0];
y = vehiclePos[1];
z = vehiclePos[2];
return 1;
}
GetXYBehindVehicle(vehicleid, &Float:q, &Float:w, Float:distance)
{
new Float:a;
GetVehiclePos(vehicleid, q, w, a);
GetVehicleZAngle(vehicleid, a);
q += (distance * -floatsin(-a, degrees));
w += (distance * -floatcos(-a, degrees));
}