SA-MP Forums Archive
[Ajuda] Rotas randomicas - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] Rotas randomicas (/showthread.php?tid=653961)



Rotas randomicas - weex - 17.05.2018

Como teria que fazer pra criar um random, entre 3 rotas e fazer uma ser a escolhida, tipo acertar esse cуdigo aqui:

Код:
new Float:rotas[][] =
{
	// rota 1
    {-12.8889,153.9808,999.7769,359.9574},
    {-14.7225,154.1146,999.7769,358.8459},
    {-17.2141,151.6454,999.7769,90.7408},
    {-17.1289,149.5033,999.7769,88.5500},
    {-16.9197,147.5242,999.7769,86.9751},
    {-17.0082,145.4394,999.7769,88.8385},
    {-4.8342,148.1478,1000.0493,7.3137},
    {-3.7265,148.7206,1000.0493,354.7095},
    {-4.7265,148.7206,1000.0493,354.7095},
    {-6.3055,153.1717,999.9245,89.3800}
    // rota 2
    {-12.8889,153.9808,999.7769,359.9574},
    {-14.7225,154.1146,999.7769,358.8459},
    {-17.2141,151.6454,999.7769,90.7408},
    {-17.1289,149.5033,999.7769,88.5500},
    {-16.9197,147.5242,999.7769,86.9751},
    {-17.0082,145.4394,999.7769,88.8385},
    {-4.8342,148.1478,1000.0493,7.3137},
    {-3.7265,148.7206,1000.0493,354.7095},
    {-4.7265,148.7206,1000.0493,354.7095},
    {-6.3055,153.1717,999.9245,89.3800}
    // rota 3
    {-12.8889,153.9808,999.7769,359.9574},
    {-14.7225,154.1146,999.7769,358.8459},
    {-17.2141,151.6454,999.7769,90.7408},
    {-17.1289,149.5033,999.7769,88.5500},
    {-16.9197,147.5242,999.7769,86.9751},
    {-17.0082,145.4394,999.7769,88.8385},
    {-4.8342,148.1478,1000.0493,7.3137},
    {-3.7265,148.7206,1000.0493,354.7095},
    {-4.7265,148.7206,1000.0493,354.7095},
    {-6.3055,153.1717,999.9245,89.3800}
};
Random Rotas :
SetPlayerCheckpointEx(playerid, X,Y,Z, 8.0);


Re: Rotas randomicas - FerrariL - 17.05.2018

PHP код:
new rand random(sizeof(rotas));
SetPlayerCheckpoint(playerid,rotas[rand][0],rotas[rand][1],rotas[rand][2],2.0); 



Re: Rotas randomicas - weex - 17.05.2018

Quote:
Originally Posted by FerrariL
Посмотреть сообщение
PHP код:
new rand random(sizeof(rotas));
SetPlayerCheckpoint(playerid,rotas[rand][0],rotas[rand][1],rotas[rand][2],2.0); 
Mas dai nгo vai seguir em escadinha, preciso que siga a rota 1 atй o fim, a rota 2 atй o fim e o msm pra rota 3


Re: Rotas randomicas - F1N4L - 17.05.2018

Uma forma com lуgica simples e sem erros...

Код:
new Float:rota_1[][] =
{
	// rota 1
    {-12.8889,153.9808,999.7769,359.9574},
    {-14.7225,154.1146,999.7769,358.8459},
    {-17.2141,151.6454,999.7769,90.7408},
    {-17.1289,149.5033,999.7769,88.5500},
    {-16.9197,147.5242,999.7769,86.9751},
    {-17.0082,145.4394,999.7769,88.8385},
    {-4.8342,148.1478,1000.0493,7.3137},
    {-3.7265,148.7206,1000.0493,354.7095},
    {-4.7265,148.7206,1000.0493,354.7095},
    {-6.3055,153.1717,999.9245,89.3800}
};

new Float:rota_2[][] =
{
	// rota 2
    {-12.8889,153.9808,999.7769,359.9574},
    {-14.7225,154.1146,999.7769,358.8459},
    {-17.2141,151.6454,999.7769,90.7408},
    {-17.1289,149.5033,999.7769,88.5500},
    {-16.9197,147.5242,999.7769,86.9751},
    {-17.0082,145.4394,999.7769,88.8385},
    {-4.8342,148.1478,1000.0493,7.3137},
    {-3.7265,148.7206,1000.0493,354.7095},
    {-4.7265,148.7206,1000.0493,354.7095},
    {-6.3055,153.1717,999.9245,89.3800}
};

new Float:rota_3[][] = 
{
	// rota 3
    {-12.8889,153.9808,999.7769,359.9574},
    {-14.7225,154.1146,999.7769,358.8459},
    {-17.2141,151.6454,999.7769,90.7408},
    {-17.1289,149.5033,999.7769,88.5500},
    {-16.9197,147.5242,999.7769,86.9751},
    {-17.0082,145.4394,999.7769,88.8385},
    {-4.8342,148.1478,1000.0493,7.3137},
    {-3.7265,148.7206,1000.0493,354.7095},
    {-4.7265,148.7206,1000.0493,354.7095},
    {-6.3055,153.1717,999.9245,89.3800}
};


	new getRandom = random(3); // {0, 1, 2}

	if(getRandom == 0)
	{
		// -- Rota 1
	}
	else if(getRandom == 1)
	{
		// -- Rota 2
	}
	else if(getRandom == 2)
	{
		// -- Rota 3
	}



Re: Rotas randomicas - weex - 21.05.2018

obg galera +rep