[FilterScript] [FS] Spikes ~ Create Realistic Road Spikes!
#7

Here Vice, just took it from my a_angles include and messed around with it a bit:

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;
}
Just use it in this fashion:
Code:
if(IsPlayerVehicleFacingPos(playerid, x, y, 180.0))
{
// pop front tires
}
else
{
// pop back tires
}
Or do what Joe said and just check their vehicle's velocity.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)