27.03.2010, 03:06
Here Vice, just took it from my a_angles include and messed around with it a bit:
Just use it in this fashion:
Or do what Joe said and just check their vehicle's velocity.
Code:
stock IsPlayerVehicleFacingPos(playerid, Float:pX, Float:pY, Float:dOffset) { new Float:pA, Float:X, Float:Y, Float:Z, Float:ang; if(!IsPlayerConnected(playerid) || !GetPlayerState(playerid) != 2) return false; GetVehiclePos(GetPlayerVehicleID(playerid), X, Y, Z); GetVehicleZAngle(GetPlayerVehicleID(playerid), pA); if( Y > pY ) ang = (-acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0); else if( Y < pY && X < pX ) ang = (acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 450.0); else if( Y < pY ) ang = (acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0); if(AngleInRangeOfAngle(-ang, pA, dOffset)) return true; return false; } stock AngleInRangeOfAngle(Float:a1, Float:a2, Float:range) { a1 -= a2; if((a1 < range) && (a1 > -range)) return true; return false; }
Code:
if(IsPlayerVehicleFacingPos(playerid, x, y, 180.0)) { // pop front tires } else { // pop back tires }