SA-MP Forums Archive
[Ajuda] Loop no dialog . - 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] Loop no dialog . (/showthread.php?tid=259546)



[Ajuda] Loop no dialog . - Ricop522 - 05.06.2011

Ajeitei o problema, obrigado pela ajuda.


Re: Loop no dialog . - TheGarfield - 05.06.2011

mande o 'carinfo'.

pawn Код:
if(strcmp(cmdtext, "/a", true) == 0)
    {
        if(pLogado[playerid] > 0)
        {
            for(new i = 1; i < sizeof(CarInfo); ++i)
            {
                if(CarInfo[i][cAVenda] == 1) format(SkillBase, sizeof(SkillBase), "Veнculo a venda: Placa: LS-%i | Qtd de donos antigos: %i | Preзo; %i\n", i, CarInfo[i][cDonos], GetVehiclePrice(i),'160');
            }
            ShowPlayerDialog(playerid,DIALOG_NADA,DIALOG_STYLE_MSGBOX,"FOREVER ALONE",SkillBase,"OK","");
           
        }
        return 0x01;
    }



Re: Loop no dialog . - Ricop522 - 05.06.2011

Ajeitei o problema, obrigado pela ajuda.


Re: Loop no dialog . - TheGarfield - 05.06.2011

LOL

tu quer exibir variбvel ?

inpossнvel!


Re: Loop no dialog . - Ricop522 - 05.06.2011

Ajeitei o problema, obrigado pela ajuda.


Re: Loop no dialog . - TheGarfield - 05.06.2011

pawn Код:
if(strcmp(cmdtext, "/felipe", true) == 0)
    {
        new string[1200+10];
        for(new i = 0; i < sizeof(CarInfo[playerid][cAVenda]); ++i)
        {
            if(CarInfo[i][cAVenda] > 0) continue;
            format(string, sizeof(string), "%i\n", CarInfo[i][cAVenda]);
        }
        ShowPlayerDialog(playerid, DIALOG_NADA, DIALOG_STYLE_LIST, "XXT:", xString, "Ok", "Exit");
        return 0x01;
    }



Re: Loop no dialog . - Falcon. - 05.06.2011

Veja bem...
pawn Код:
for(new i = 0; i < sizeof(CarInfo); ++i)
        {
            if(CarInfo[i][cAVenda] > 0) continue;
            format(string, sizeof(string), "%i\n", i);
        }
A cada vez que ele realizar o loop ele vai atribuir um valor diferente a string, ou seja, vai refazela.
Apуs ele terminar todo o loop ele vai enviar a sua string formatada para o seu dialog, o ultimo valor decorrido nela foi o 1199...Eis o motivo disto !!

Entгo isto que vocк estб querendo fazer atй aonde meu conhecimento conssegue chegar nгo й possнvel
(realmente pode existir uma forma de se fazer isto, mбs deste geito nгo irб funcionar)

Vou ver se conssigo elaborar algo e postarei(caso alguйm nгo poste antes)


Re: Loop no dialog . - rjjj - 05.06.2011

Bem, bastaria usar strins ou strcat para unir todas as strings que representam um ъnico veнculo, em um stringгo sу .



O que poderia tornar isso impossнvel seria a capacidade de caracteres do parвmetro info[] da funзгo ShowPlayerDialog, mas jб testei sistemas de Spawn de Carros no qual todos os carros estavam listados em um ъnico Dialog, por isso nгo deverб ocorrer problemas nessa parte .



Isto deve resolver o seu problema .


pawn Код:
if(strcmp(cmd, "/felipe", true) == 0)
    {
        new Stringao[(sizeof(CarInfo)*72)];//O tamanho adaptado б quantidade de veiculos. Qualquer coisa basta diminui o nъmero de cells :D
        if(pLogado[playerid] > 0)
        {
            for(new i = 1; i < sizeof(CarInfo); ++i)
            {
                if(CarInfo[i][cAVenda] == 1)
                {
                    format(SkillBase, sizeof(SkillBase), "Veнculo a venda: Placa: LS-%i | Qtd de donos antigos: %i | Preзo; %i\n", i, CarInfo[i][cDonos], GetVehiclePrice(i));
                    strins(Stringao, SkillBase, strlen(Stringao), sizeof(Stringao));
                }
            }
            ShowPlayerDialog(playerid,DIALOG_NADA,DIALOG_STYLE_LIST,"FOREVER ALONE",Stringao,"OK","");
        }
        return 0x1;
    }


Se nгo funcionar, ordene manualmente os 1200 veнculos e vб usando format pra juntar um por um no format do Stringao .



Quote:
Originally Posted by Falcon.Sixe
Посмотреть сообщение
(caso alguйm nгo poste antes)




Espero ter ajudado .


Re: Loop no dialog . - steki. - 05.06.2011

Use strcat para unir as variбveis.


Re: Loop no dialog . - Ricop522 - 05.06.2011

Ajeitei o problema.
Grato pela ajuda (: