//***********************************
//*************By Vadia**************
//***********************************

#include <a_samp>
#define COLOR_LIME 0x10F441AA
new shar[5];
new timer[5];
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);

public OnFilterScriptInit()
{
    Create3DTextLabel("[введите /fly1]\nМаршрут:Los Santos",COLOR_LIME,28.4640,-104.8852,0.6094,20.0,0);//1
    Create3DTextLabel("[введите /fly2]\nМаршрут:San Fierro",COLOR_LIME,-11.3330,-65.0707,3.1172,20.0,0);//2
    Create3DTextLabel("[введите /fly3]\nМаршрут:Prison",COLOR_LIME,17.1257,-37.8144,3.1462,20.0,0);//3
    Create3DTextLabel("[введите /fly4]\nМаршрут:Las Venturas",COLOR_LIME,-16.9834,-13.7061,3.1462,20.0,0);//4*/
    Create3DTextLabel("Введите /clothes для смены одежды",COLOR_LIME,161.3998,-83.8033,1001.8047,40.0,0);
	shar[1] = CreateObject(19332,28.5078,-104.8904,1.0,0.00000000,0.00000000,0.00000000); //Шар1
    shar[2] = CreateObject(19335,-11.1980,-65.2409,2.0,0.00000000,0.00000000,0.00000000); //Шар2
    shar[3] = CreateObject(19334,17.2916,-37.9901,2.0,0.00000000,0.00000000,0.00000000); //Шар3
    shar[4] = CreateObject(19336,-16.9694,-13.7086,2.0,0.00000000,0.00000000,0.00000000); //Шар4
    print("**************");
    print("***By Vadia***");
    print("**************");
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp(cmdtext, "/fly1", true) == 0)
{
    if(PlayerToPoint(2.0,playerid,28.4640,-104.8852,0.6094))
    {
        MoveObject(shar[1],28.5078,-104.8904,154.6683, 4.0);
        timer[1] = SetTimer("sharfly", 30000, 0);
        SendClientMessage(playerid,0x15AAEAAA,"Вы начали подъём. Маршрут:Los Santos");
    }
    return 1;
}
if (strcmp(cmdtext, "/fly2", true) == 0)
{
    if(PlayerToPoint(2.0, playerid,-11.3330,-65.0707,3.1172))
    {
        MoveObject(shar[2],-11.1980,-65.2409,154.6683, 4.0);
        timer[2] = SetTimer("sharflys", 30000, 0);
        SendClientMessage(playerid,0x15AAEAAA,"Вы начали подъём. Маршрут:San Fierro");
    }
    return 1;
}
if (strcmp(cmdtext, "/fly3", true) == 0)
{
    if(PlayerToPoint(2.0, playerid,17.1257,-37.8144,3.1462))
    {
        MoveObject(shar[3],17.2916,-37.9901,154.6683, 4.0);
        timer[3] = SetTimer("sharflyz", 30000, 0);
        SendClientMessage(playerid,0x15AAEAAA,"Вы начали подъём. Маршрут:Prison");
    }
    return 1;
}
if (strcmp(cmdtext, "/fly4", true) == 0)
{
    if(PlayerToPoint(2.0, playerid,-16.9834,-13.7061,3.1462))
    {
        MoveObject(shar[4],-16.9694,-13.7086,154.6683, 4.0);
        timer[4] = SetTimer("sharflye", 30000, 0);
        SendClientMessage(playerid,0x15AAEAAA,"Вы начали подъём. Маршрут:Las Venturas");
    }
    return 1;
}
return 0;
}
//fly1
forward sharfly();
public sharfly()
{
	MoveObject(shar[1],1727.9158,-1837.3203,154.6683, 9.0);
    timer[1] = SetTimer("sharfly1", 120000, 0);
	return 1;
}

forward sharfly1();
public sharfly1()
{
	MoveObject(shar[1],1727.9158,-1837.3203,154.6683, 9.0);
    timer[1] = SetTimer("sharfly2", 10000, 0);
	return 1;
}

forward sharfly2();
public sharfly2()
{
	MoveObject(shar[1],28.5078,-104.8904,154.6683, 9.0);
	timer[1] = SetTimer("sharfly3", 120000, 0);
	return 1;
}

forward sharfly3();
public sharfly3()
{
	MoveObject(shar[1],28.5078,-104.8904,1.0, 4.0);
	return 1;
}
// fly2
forward sharflys();
public sharflys()
{
	MoveObject(shar[2],-2294.3625,-40.8863,135.7250, 9.0);
    timer[2] = SetTimer("sharflys1", 120000, 0);
	return 1;
}

forward sharflys1();
public sharflys1()
{
	MoveObject(shar[2],-2294.3625,-40.8863,135.7250, 9.0);
    timer[2] = SetTimer("sharflys2", 10000, 0);
	return 1;
}

forward sharflys2();
public sharflys2()
{
	MoveObject(shar[2],-11.1980,-65.2409,154.6683, 9.0);
	timer[2] = SetTimer("sharflys3", 120000, 0);
	return 1;
}

forward sharflys3();
public sharflys3()
{
	MoveObject(shar[2],-11.1980,-65.2409,1.5, 4.0);
	return 1;
}
//fly3
forward sharflyz();
public sharflyz()
{
	MoveObject(shar[3],2249.9600,2081.0979,167.5553, 9.0);
    timer[3] = SetTimer("sharflyz1", 120000, 0);
	return 1;
}

forward sharflyz1();
public sharflyz1()
{
	MoveObject(shar[3],2249.9600,2081.0979,167.5553, 9.0);
    timer[3] = SetTimer("sharflyz2", 10000, 0);
	return 1;
}

forward sharflyz2();
public sharflyz2()
{
	MoveObject(shar[3],17.2916,-37.9901,154.6683, 9.0);
	timer[3] = SetTimer("sharflyz3", 120000, 0);
	return 1;
}

forward sharflyz3();
public sharflyz3()
{
	MoveObject(shar[3],17.2916,-37.9901,2.0, 4.0);
	return 1;
}
//fly4
forward sharflye();
public sharflye()
{
	MoveObject(shar[4],193.3858,1866.5685,109.3741, 9.0);
    timer[4] = SetTimer("sharflye1", 180000, 0);
	return 1;
}

forward sharflye1();
public sharflye1()
{
	MoveObject(shar[4],193.3858,1866.5685,109.3741, 9.0);
    timer[4] = SetTimer("sharflye2", 10000, 0);
	return 1;
}

forward sharflye2();
public sharflye2()
{
	MoveObject(shar[4],-16.9694,-13.7086,154.6683, 9.0);
	timer[4] = SetTimer("sharflye3", 120000, 0);
	return 1;
}

forward sharflye3();
public sharflye3()
{
	MoveObject(shar[4],-16.9694,-13.7086,2.0, 4.0);
	return 1;
}

public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
    if(IsPlayerConnected(playerid))
	{
		new Float:oldposx, Float:oldposy, Float:oldposz;
		new Float:tempposx, Float:tempposy, Float:tempposz;
		GetPlayerPos(playerid, oldposx, oldposy, oldposz);
		tempposx = (oldposx -x);
		tempposy = (oldposy -y);
		tempposz = (oldposz -z);
		//printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
		if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
		{
			return 1;
		}
	}
	return 0;
}
