#define CCOUNT 16
#define COLOR_INTERFACE 0xFFFFFFFF

new NamePos[7][] = {
	"City hall","Driving school","Central Bank","The work of the loader","Sawmill","The work of the miner","Plant"
};

new Float:C[CCOUNT][6] = {
{1410.255249, -1686.357910, 54.367927, 1479.179565, -1563.238159, 82.259399},
{1413.777343, -1689.270019, 52.339508, 1479.046997, -1567.992065, 80.715927},
{-1985.337768, -79.023513, 46.770477, -2087.135498, -45.985202, 61.119033},
{-1990.123291, -80.063621, 45.761821, -2085.070556, -50.052639, 59.071674},
{1261.389404, 1015.367980, 80.901000, 1057.909790, 1236.603759, 53.091159},
{1256.777221, 1016.601623, 79.415939, 1058.501708, 1231.702758, 52.297653},
{2183.060791, -2226.707519, 29.169836, 2249.402099, -2205.250976, 26.542779},
{2186.943115, -2229.080810, 27.097560, 2245.644042, -2208.182373, 25.031629},
{2397.670654, -607.482543, 152.338272, 2370.194335, -670.164611, 133.132568},
{2395.194335, -611.399047, 150.459747, 2366.694580, -666.731262, 132.150711},
{-1934.119506, -1788.213745, 86.987350, -1788.706665, -1678.037109, 51.675411},
{-1932.197753, -1784.142089, 84.812805, -1791.942138, -1675.129394, 49.210296},
{-159.742904, -425.997253, 58.206382, -11.919424, -374.713806, 34.663837},
{-157.389007, -422.157379, 56.035072, -15.093905, -371.279876, 32.894424},
{443.818176, -1922.658691, 40.499740, 344.222534, -1970.671020, 26.009180},
{441.308807, -1926.882568, 39.571563, 346.455718, -1975.125488, 25.595594}
};

new Text:Intro[4];
new PlayerText:PosInfo[MAX_PLAYERS];
new gCurPos[MAX_PLAYERS];
new NamePosP[MAX_PLAYERS];
new gDelay[CCOUNT] = {4875,4875,4875,4875,4875,4875,4875,4875,4875,4875,4875,4875,4875,4875,7375,7375};

forward GoIntro(playerid);
public GoIntro(playerid)
{
	gCurPos[playerid] = 0;	
	NamePosP[playerid] = 0;	
	PlayAudioStreamForPlayer(playerid,"http://sanandreas-rp.ru/music/Intro.mp3");
	for(new c = 0; c < 20; c++) SendClientMessage(playerid,0xEAC700AA," ");
	SetPlayerWeather(playerid,1);
	SetTimerEx("StartIntro",100,false,"i",playerid);
	TextDrawShowForPlayer(playerid,Intro[3]);
	
	PosInfo[playerid] = CreatePlayerTextDraw(playerid, 320.333374, 420.622283, "_");
	PlayerTextDrawLetterSize(playerid, PosInfo[playerid], 0.449999, 1.600000);
	PlayerTextDrawAlignment(playerid, PosInfo[playerid], 2);
	PlayerTextDrawColor(playerid, PosInfo[playerid], -356056918);
	PlayerTextDrawSetShadow(playerid, PosInfo[playerid], 0);
	PlayerTextDrawSetOutline(playerid, PosInfo[playerid], 1);
	PlayerTextDrawBackgroundColor(playerid, PosInfo[playerid], 51);
	PlayerTextDrawFont(playerid, PosInfo[playerid], 2);
	PlayerTextDrawSetProportional(playerid, PosInfo[playerid], 1);
	PlayerTextDrawShow(playerid, PosInfo[playerid]);
}

forward StartIntro(playerid);
public StartIntro(playerid)
{
	SetPlayerInterior(playerid,0);
	SetPlayerVirtualWorld(playerid,0);
	TogglePlayerControllable(playerid,0);	
	t_SetPlayerPos(playerid,1479.2852,-1777.2365,13.5469);
	new p = gCurPos[playerid];
	new d = gDelay[p];
	if(p < 15) 
	{
		new string[65];
		InterpolateCameraPos(playerid,C[p][0],C[p][1],C[p][2],C[p][3],C[p][4],C[p][5],d,CAMERA_MOVE);
		InterpolateCameraLookAt(playerid,C[p+1][0],C[p+1][1],C[p+1][2],C[p+1][3],C[p+1][4],C[p+1][5],d,CAMERA_MOVE);
		format(string,65,"%s", NamePos[NamePosP[playerid]]);
		PlayerTextDrawSetString(playerid, PosInfo[playerid], string);
		SetTimerEx("NextPoint",d,false,"i",playerid);
	}
}

forward NextPoint(playerid);
public NextPoint(playerid)
{
	NamePosP[playerid] += 1;
	gCurPos[playerid] += 2;
	new p = gCurPos[playerid];	
	if(p < 15) 
	{
		new string[65];
		new d = gDelay[p];
		if(p == 2) t_SetPlayerPos(playerid,-2028.7310,-109.5846,35.1582);
		if(p == 4) t_SetPlayerPos(playerid,1031.6440,1005.9446,48.1328);
		if(p == 6) t_SetPlayerPos(playerid,2205.2571,-2254.3340,13.5469);
		if(p == 8) t_SetPlayerPos(playerid,2353.3130,-646.6732,128.0620);
		if(p == 10) t_SetPlayerPos(playerid,-1817.6398,-1674.1859,21.8547);
		if(p == 12) t_SetPlayerPos(playerid,-85.0041,-224.4521,41.2267);
		if(p == 14) t_SetPlayerPos(playerid,365.2382,-2062.2542,7.8359);
		InterpolateCameraPos(playerid,C[p][0],C[p][1],C[p][2],C[p][3],C[p][4],C[p][5],d,CAMERA_MOVE);
		InterpolateCameraLookAt(playerid,C[p+1][0],C[p+1][1],C[p+1][2],C[p+1][3],C[p+1][4],C[p+1][5],d,CAMERA_MOVE);
		SetTimerEx("NextPoint",d,false,"i",playerid);
		if(p != 14)
		{
			format(string,65,"%s", NamePos[NamePosP[playerid]]);
			PlayerTextDrawSetString(playerid, PosInfo[playerid], string);
		}
		if(p == 14)
		{
			PlayerTextDrawDestroy(playerid,PosInfo[playerid]);  
			TextDrawHideForPlayer(playerid,Intro[3]);
			TextDrawShowForPlayer(playerid,Intro[0]);
			TextDrawShowForPlayer(playerid,Intro[1]);
			TextDrawShowForPlayer(playerid,Intro[2]);
		}
	}
	else
	{
		StopAudioStreamForPlayer(playerid);
		TogglePlayerControllable(playerid,1);
		TextDrawHideForPlayer(playerid, Intro[0]);
        TextDrawHideForPlayer(playerid, Intro[1]);
        TextDrawHideForPlayer(playerid, Intro[2]);
		t_SetPlayerPos(playerid, 827.1293,-1370.8298,-0.5015);
 		SetPlayerVirtualWorld(playerid,0);
 		SetPlayerInterior(playerid,0);
		SetCameraBehindPlayer(playerid);
		SetPlayerChatBubble(playerid, "Вышел из поезда", 0xEAC700AA, 20.0, 7000);
		SetPVarInt(playerid, "QuestsPhone", 11);
	}
}

stock IntroTextDraw()
{
    Intro[0] = TextDrawCreate(320.000000, 180.000000, "SanAndreas");
    TextDrawAlignment(Intro[0], 2);
	TextDrawFont(Intro[0], 1);
	TextDrawColor(Intro[0], 0xFF8501FF);
	TextDrawSetShadow(Intro[0], 0);
	TextDrawSetOutline(Intro[0], -1);
	TextDrawBackgroundColor(Intro[0], 51);
	TextDrawLetterSize(Intro[0], 1.14, 3.599998);

	Intro[1] = TextDrawCreate(180.000030, 207.5, ".");
	TextDrawLetterSize(Intro[1], 30.247341, 0.650074);
	TextDrawAlignment(Intro[1], 1);
	TextDrawColor(Intro[1], -1);
	TextDrawSetShadow(Intro[1], 0);
	TextDrawSetOutline(Intro[1], -1);
	TextDrawBackgroundColor(Intro[1], 51);
	TextDrawFont(Intro[1], 3);
	TextDrawSetProportional(Intro[1], 1);

	Intro[2] = TextDrawCreate(320.00, 210.0, "Role Play");
	TextDrawAlignment(Intro[2], 2);
	TextDrawFont(Intro[2], 1);
	TextDrawColor(Intro[2], 0xFF8501FF);
	TextDrawSetShadow(Intro[2], 0);
	TextDrawSetOutline(Intro[2], -1);
	TextDrawBackgroundColor(Intro[2], 51);
	TextDrawLetterSize(Intro[2], 1.14, 3.599998);
	
	Intro[3] = TextDrawCreate(448.666687, 408.018890, "usebox");
	TextDrawLetterSize(Intro[3], 0.000000, 4.338477);
	TextDrawTextSize(Intro[3], 192.000000, 0.000000);
	TextDrawAlignment(Intro[3], 1);
	TextDrawColor(Intro[3], 0);
	TextDrawUseBox(Intro[3], true);
	TextDrawBoxColor(Intro[3], 102);
	TextDrawSetShadow(Intro[3], 0);
	TextDrawSetOutline(Intro[3], 0);
	TextDrawFont(Intro[3], 0);
	return true;
}