13.05.2016, 17:07
Hi guys,
So i wanted to make a loop in a command so it waited til a variable turned 1 or 2.
As you can see theres a dialog being created wich will give the player 2 options and when he chooses them it turns escolhacombustivel[playerid] into value 1. So what i really wanted is for the command to wait until the player gives a response to the dialog and then continue with the script. Is there any way to do it? If not is there a way to take some variables from this command and put them in the OnDialogResponse?
Cumpz,
vasco
So i wanted to make a loop in a command so it waited til a variable turned 1 or 2.
PHP код:
if(strcmp(cmd, "/comprarveiculo", true) == 0)
{
if(PlayerToPoint(10.0, playerid,345.5447,160.1090,1014.1875))
{
if(PlayerInfo[playerid][pChave1] == 255 || PlayerInfo[playerid][pChave2] == 255 || PlayerInfo[playerid][pChave3] == 255 || PlayerInfo[playerid][pChave4] == 255 || PlayerInfo[playerid][pChave5] == 255 || PlayerInfo[playerid][pChave6] == 255)
{
for(new i = 0; i < sizeof(Businesses); i++)
{
if(PlayerToPoint(25.0, playerid,Businesses[i][ExitX], Businesses[i][ExitY], Businesses[i][ExitZ]))
{
if(GetPlayerVirtualWorld(playerid) == i)
{
if(Businesses[i][BizType] == 9)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_LIGHTRED,"{ADFF2F}[Comando]: {FFFFFF} /comprarveiculo [ID do Modelo do Veiculo]");
return 1;
}
new TCarModel = strval(tmp);
for(new c=0;c<MAX_VEHICLES;c++)
{
if(DynamicCars[c][comprado] == 0) // Nгo comprado
{
if(DynamicCars[c][valor] == 0) // Sem Preзo
{
if(DynamicCars[c][buy] == 1) // Para venda
{
if(DynamicCars[c][CarModel] == 481)
{
if(IsValidModel(TCarModel))
{
if( TCarModel == 509 || TCarModel == 481|| TCarModel == 510)
{
SendClientMessage(playerid, COLOR_RED,"{FF0000}[Erro]: {FFFFFF}Modelo Invбlido.");
return 1;
}
new valorveiculo = TCarModel-400;
new precoveiculo = VehiclePrices[valorveiculo][0];
if (PlayerInfo[playerid][pVipActive] == 0 && precoveiculo <= GetPlayerEuros(playerid) || PlayerInfo[playerid][pVipActive] != 0 && precoveiculo/2 <= GetPlayerEuros(playerid))
{
ShowPlayerDialog(playerid, 1069, DIALOG_STYLE_LIST, "Escolhe o tipo de combustivel:","Gasoleo\nGasolina","Escolher", "Cancelar");
while(escolhacombustivel[playerid] == 0)
{
return 1;
}
if(escolhacombustivel[playerid] == 1)
{
if(tipocombustivel[playerid] == 2)
{
precoveiculo *= 1.1;
}
SendClientMessage(playerid, COLOR_GREY, "========================================================================================================");
SendClientMessage(playerid, COLOR_WHITE, "Compraste o veiculo com sucesso. Este aparecerб na marinha de Palomino Creek em 10 horas ingame");
SendClientMessage(playerid, COLOR_GREY, "========================================================================================================");
SetTimerEx("buyvehtime", 2000, false, "iii", playerid, TCarModel, c);
if(PlayerInfo[playerid][pVipActive] != 0)
{
GivePlayerEuros(playerid, -precoveiculo/2);
Businesses[i][Products]=Businesses[i][Products]-(precoveiculo/2/100);
Businesses[i][Till]+=precoveiculo;
OnPlayerDataSave(playerid);
}
else
{
GivePlayerEuros(playerid, -precoveiculo);
Businesses[i][Products]=Businesses[i][Products]-(precoveiculo/100);
Businesses[i][Till]+=precoveiculo;
}
if(PlayerInfo[playerid][pChave1] == 255)
{
PlayerInfo[playerid][pChave1] = c+1;
return 1;
}
else if(PlayerInfo[playerid][pChave2] == 255)
{
PlayerInfo[playerid][pChave2] = c+1;
return 1;
}
else if(PlayerInfo[playerid][pChave3] == 255)
{
PlayerInfo[playerid][pChave3] = c+1;
return 1;
}
else if(PlayerInfo[playerid][pChave4] == 255)
{
PlayerInfo[playerid][pChave4] = c+1;
return 1;
}
else if(PlayerInfo[playerid][pChave5] == 255)
{
PlayerInfo[playerid][pChave5] = c+1;
return 1;
}
else if(PlayerInfo[playerid][pChave6] == 255)
{
PlayerInfo[playerid][pChave6] = c+1;
return 1;
}
}
}
else
{
SendClientMessage(playerid, COLOR_RED,"{FF0000}[Erro]: {FFFFFF}Nгo tens dinheiro suficiente!");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_RED,"{FF0000}[Erro]: {FFFFFF}Modelo Invбlido.");
return 1;
}
}
}
}
}
}
return 1;
}
}
}
}
}
else
{
SendClientMessage(playerid, COLOR_RED,"{FF0000}[Erro]: {FFFFFF}Jб tens seis carros nгo podes ter mais!");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_RED,"{FF0000}[Erro]: {FFFFFF}Nгo estas no stand!");
return 1;
}
}
Cumpz,
vasco