Looping in a command
#1

Hi guys,
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.0playerid,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 
0sizeof(Businesses); i++)
                    {
                        if(
PlayerToPoint(25.0playerid,Businesses[i][ExitX], Businesses[i][ExitY], Businesses[i][ExitZ]))
                        {
                            if(
GetPlayerVirtualWorld(playerid) == i)
                            {
                                if(
Businesses[i][BizType] == 9)
                                {
                                    
tmp strtok(cmdtextidx);
                                    if(!
strlen(tmp))
                                    {
                                        
SendClientMessage(playeridCOLOR_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(playeridCOLOR_RED,"{FF0000}[Erro]: {FFFFFF}Modelo Invбlido.");
                                                                return 
1;
                                                            }
                                                            new 
valorveiculo TCarModel-400;
                                                            new 
precoveiculo VehiclePrices[valorveiculo][0];
                                                              if (
PlayerInfo[playerid][pVipActive] == && precoveiculo <= GetPlayerEuros(playerid) || PlayerInfo[playerid][pVipActive] != && precoveiculo/<= GetPlayerEuros(playerid))
                                                            {
                                                                
ShowPlayerDialog(playerid1069DIALOG_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(playeridCOLOR_GREY"========================================================================================================");
                                                                    
SendClientMessage(playeridCOLOR_WHITE"Compraste o veiculo com sucesso. Este aparecerб na marinha de Palomino Creek em 10 horas ingame");
                                                                    
SendClientMessage(playeridCOLOR_GREY"========================================================================================================");
                                                                    
SetTimerEx("buyvehtime"2000false"iii"playeridTCarModelc);
                                                                    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(playeridCOLOR_RED,"{FF0000}[Erro]: {FFFFFF}Nгo tens dinheiro suficiente!");
                                                                return 
1;
                                                            }
                                                        }
                                                        else
                                                        {
                                                            
SendClientMessage(playeridCOLOR_RED,"{FF0000}[Erro]: {FFFFFF}Modelo Invбlido.");
                                                            return 
1;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                       return 
1;
                                   }
                            }
                        }
                    }
                }
                else
                {
                    
SendClientMessage(playeridCOLOR_RED,"{FF0000}[Erro]: {FFFFFF}Jб tens seis carros nгo podes ter mais!");
                    return 
1;
                 }
            }
            else
            {
                
SendClientMessage(playeridCOLOR_RED,"{FF0000}[Erro]: {FFFFFF}Nгo estas no stand!");
                return 
1;
             }
        } 
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
Reply
#2

You can put the rest code to OnDialogResponse, where you cange the variable escolhacombustivel to 1.

I mean like this.

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1069)
    {
        if(response) // Escolher
        {
            // Set the variable to 1
            escolhacombustivel[playerid] = 1;

            // The rest code
            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 // Cancelar
        {

        }
        return 1;
    }
 
    return 0;
}
Reply
#3

and it still recognizes the variables that are in the command too?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)