// ***** Special Functions by ONEhelsING
#include <a_players>
#pragma tabsize 0


/*
native IsPlayerInCircle(playerid,Float:x,Float:y,radius);
native IsPlayerInCubeArea(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy, Float:minz, Float:maxz);
native GetPlayerDistanceToPoint(playerid,Float:x,Float:y);
native GetDistanceXYZtoXYZ(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2);
native GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance);
native GetDistancePlayertoXYZ(playerid,Float:x2,Float:y2,Float:z2);
native GetDistanceBetweenVehicles(v1,v2);
native PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
native loccmp(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2);
native GiveVehicleHealth(vehicleid,Float:heal);
native ExploseVehicle(vehicleid);
*/

stock IsPlayerInCircle(playerid,Float:x,Float:y,radius) //By Sacky
	{
	if(GetPlayerDistanceToPoint(playerid,x,y) < radius)
		{
		return 1;
		}
	return 0;
	}

stock GetPlayerDistanceToPoint(playerid,Float:x,Float:y) //By Sacky
	{
	new Float:x1,Float:y1,Float:z1;
	new Float:tmpdis;
	GetPlayerPos(playerid,x1,y1,z1);
	tmpdis = floatsqroot(floatpower(floatabs(floatsub(x,x1)),2)+floatpower(floatabs(floatsub(y,y1)),2));
	return floatround(tmpdis);
	}
stock IsPlayerInCubeArea(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy, Float:minz, Float:maxz)
	{
	new Float:x, Float:y, Float:z;
	GetPlayerPos(playerid, x, y, z);
	if (x > minx && x < maxx && y > miny && y < maxy && z > minz && z < maxz) return 1;
	return 0;
	}
stock GetDistanceBetweenVehicles(v1,v2)
	{
	new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
	new Float:tmpdis;
	GetVehiclePos(v1,x1,y1,z1);
	GetVehiclePos(v2,x2,y2,z2);
	tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
	return floatround(tmpdis);
	}
stock GiveVehicleHealth(vehicleid,Float:heal) {
	new Float:vh1;
	GetVehicleHealth(vehicleid,vh1);
	SetVehicleHealth(vehicleid,vh1+heal);
	return 1;
	}
stock ExploseVehicle(vehicleid)
{
	for (new i=0; i < MAX_PLAYERS; i++)
		{
		if (GetPlayerVehicleID(i) == vehicleid)
			{
			SetPlayerHealth(i,0);
			}
		}
	new Float:vX, Float:vY, Float:vZ;
	SetVehicleHealth(vehicleid,0);
	GetVehiclePos(vehicleid,vX,vY,vZ);
	for(new e = 0; e < 6; e++)
 	    {
 		CreateExplosion(vX, vY, vZ, 6, 1);
 		SetVehiclePos(vehicleid,vX,vY,vZ-2.0);
 		}
	return 1;
}

stock Float:GetDistancePlayertoXYZ(playerid,Float:x2,Float:y2,Float:z2)
{
	if (!IsPlayerConnected(playerid)) {return 65000.0;}
	new Float:x1, Float:y1, Float:z1;
	GetPlayerPos(playerid,x1,y1,z1);
	new Float:dist = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
	return dist;
}

stock PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
	if (GetDistancePlayertoXYZ(playerid,x,y,z) < radi)
	{
		return 1;
	}
	return 0;
}

stock Float:GetDistanceXYZtoXYZ(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2)
{
	new Float:dist = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
	return dist;
}

stock loccmp(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2)
{
	if ((x1 == x2) && (y1 == y2) && (z1 == z2)) return 1;
	return 0;
}

stock Float:GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
    new Float:a;
	GetPlayerPos(playerid, x, y, a);
	if (IsPlayerInAnyVehicle(playerid)) GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
	else GetPlayerFacingAngle(playerid, a);
	x += (distance * floatsin(-a, degrees));
	y += (distance * floatcos(-a, degrees));
	return a;
}
