SA-MP Forums Archive
[Ajuda] Como eu poderia fazer este "if" identificar todos estes veiculos? - 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] Como eu poderia fazer este "if" identificar todos estes veiculos? (/showthread.php?tid=643558)



Como eu poderia fazer este "if" identificar todos estes veiculos? - Kledson - 22.10.2017

Bom ontem o Rato22 me ajudou a fazer isso aqui:
PHP код:
new specialcar[24]; 
PHP код:
specialcar[0] = AddStaticVehicleEx(456,-590.4003900,-473.7002000,25.8000000,177.9950000,93,126,15); //Yankee 
specialcar[1] = AddStaticVehicleEx(456,-579.5999800,-473.6000100,25.8000000,179.9950000,93,126,15); //Yankee 
specialcar[2] = AddStaticVehicleEx(456,-569.0999800,-474.0000000,25.8000000,179.9950000,93,126,15); //Yankee 
specialcar[3] = AddStaticVehicleEx(456,-559.5999800,-473.8999900,25.8000000,179.9950000,93,126,15); //Yankee 
specialcar[4] = AddStaticVehicleEx(456,-549.5999800,-474.2000100,25.8000000,179.9950000,93,126,15); //Yankee 
specialcar[5] = AddStaticVehicleEx(456,-539.5999800,-473.7999900,25.8000000,179.9950000,93,126,15); //Yankee 
specialcar[6] = AddStaticVehicleEx(456,-534.4003900,-474.2002000,25.8000000,179.9950000,93,126,15); //Yankee 
specialcar[7] = AddStaticVehicleEx(456,-529.9003900,-474.0996100,25.8000000,179.9950000,93,126,15); //Yankee 
specialcar[8] = AddStaticVehicleEx(456,-524.5000000,-474.3999900,25.8000000,179.9950000,93,126,15); //Yankee 
specialcar[9] = AddStaticVehicleEx(456,-519.2000100,-474.5000000,25.8000000,179.9950000,93,126,15); //Yankee 
specialcar[10] = AddStaticVehicleEx(456,-514.2000100,-474.7999900,25.8000000,179.9950000,93,126,15); //Yankee 
specialcar[11] = AddStaticVehicleEx(456,-514.2002000,-474.7998000,25.8000000,179.9950000,93,126,15); //Yankee 
specialcar[12] = AddStaticVehicleEx(456,-509.2000100,-475.1000100,25.8000000,179.9950000,93,126,15); //Yankee 
specialcar[13] = AddStaticVehicleEx(456,-504.2000100,-474.7999900,25.8000000,179.9950000,93,126,15); //Yankee 
specialcar[14] = AddStaticVehicleEx(456,-499.3999900,-474.5000000,25.8000000,179.9950000,93,126,15); //Yankee 
specialcar[15] = AddStaticVehicleEx(456,-494.8999900,-474.7000100,25.8000000,179.9950000,93,126,15); //Yankee 
specialcar[16] = AddStaticVehicleEx(456,-489.6000100,-474.3999900,25.8000000,179.9950000,93,126,15); //Yankee 
specialcar[17] = AddStaticVehicleEx(456,-479.5996100,-474.0996100,25.8000000,179.9950000,93,126,15); //Yankee 
specialcar[18] = AddStaticVehicleEx(414,-584.7999900,-475.0000000,25.7000000,180.0000000,95,10,15); //Mule 
specialcar[19] = AddStaticVehicleEx(414,-574.7999900,-475.1000100,25.5000000,180.0000000,95,10,15); //Mule 
specialcar[20] = AddStaticVehicleEx(414,-565.2000100,-474.5000000,25.7000000,180.0000000,95,10,15); //Mule 
specialcar[21] = AddStaticVehicleEx(414,-555.0000000,-474.3999900,25.7000000,180.0000000,95,10,15); //Mule 
specialcar[22] = AddStaticVehicleEx(414,-544.7999900,-474.2999900,25.7000000,180.0000000,95,10,15); //Mule 
specialcar[23] = AddStaticVehicleEx(414,-484.2999900,-474.3999900,25.8000000,179.9950000,93,126,15); //Mule
__________________ 
Agradeзo o Rato22 por ajudar nesta parte pra criaзao correta da variavel, mas a duvida ao usar o "if" ficou no ar , tipo:
PHP код:
if(IsPlayerInVehicle(playeridspecialcar[0])) 
Se eu deixar este "verificador" assim obviamente ele vai pegar sу no primeiro caminhгo o comando, jб tentei botar varias if debaixo do outro, atй compilou mas enxeu de warning e o comando no server tinha atй dado "Unkown Command"

Como devo fazer este if pegar em todos esses veiculos com a variavel "specialcar"?


Re: Como eu poderia fazer este "if" identificar todos estes veiculos? - IlanZ - 22.10.2017

PHP код:
for(new i24i++)
{
    if(
IsPlayerInVehicle(playeridspecialcar[i]))  




Re: Como eu poderia fazer este "if" identificar todos estes veiculos? - Kledson - 22.10.2017

Quote:
Originally Posted by IlanZ
Посмотреть сообщение
PHP код:
for(new i24i++)
{
    if(
IsPlayerInVehicle(playeridspecialcar[i]))  

Aonde coloco esta linha for(new i; i < 24; i++)? desculpa , mas preciso perguntar pq sу estou usando o pawno a apenas uma semana


Re: Como eu poderia fazer este "if" identificar todos estes veiculos? - Chefгo - 22.10.2017

poder ser na
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)



Re: Como eu poderia fazer este "if" identificar todos estes veiculos? - IlanZ - 22.10.2017

PHP код:
public OnPlayerStateChange(playeridnewstateoldstate)
{
    for(new 
i24i++)
    { 
        if(
oldstate == PLAYER_STATE_ONFOOT && IsPlayerInVehicle(playeridspecialcar[i]) && newstate == PLAYER_STATE_DRIVER)
        {
            
SendClientMessage(playerid, -1"Vocк entrou em um carro especial");
        }
    }
    return 
1;




Re: Como eu poderia fazer este "if" identificar todos estes veiculos? - Gguiz - 23.10.2017

Quote:
Originally Posted by FrajolaGR
Посмотреть сообщение
Код:
for(new i; i < sizeof(specialcar); i++)
{
	if(IsPlayerInVehicle(playerid, specialcar[i]))
	{

	}
}
Nгo entendi porquк vocк abriu essa chave, й totalmente desnecessбrio.

PHP код:
    if(IsPlayerInVehicle(playeridspecialcar[i]))
    {
    } 



Re: Como eu poderia fazer este "if" identificar todos estes veiculos? - Gguiz - 23.10.2017

Quote:
Originally Posted by FrajolaGR
Посмотреть сообщение
So dei um exemplo de como ele pode verificar todos veнculos que pertence a specialcar.
Isso eu sei, vocк usou o loop. Porйm o IlanZ jб deu a resposta necessбria, entгo jб era um tуpico respondido.