SA-MP Forums Archive
[Ajuda] Exibir players em dialogo - 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] Exibir players em dialogo (/showthread.php?tid=358217)



Exibir players em dialogo - [XPG]MarlonCS - 09.07.2012

O que faзo para exibir os players que estгo sendo procurados em um dialogo?

procurado[playerid]=1;
/\ Esses sгo os players procurados.


Re: Exibir players em dialogo - .FuneraL. - 09.07.2012

pawn Код:
new string[200], string2[200], Nome[24];
GetPlayerName(playerid, Nome, sizeof(Nome));
for(new i = 0; i < MAX_PLAYERS; i++)
{
     if(procurado[i] > 0)
     {
          format(string, sizeof(string), "%s", Nome);
          strcat(string, string2, sizeof(string));
     }
     ShowPlayerDialog(playerid, 10, DIALOG_STYLE_MSGBOX, "Procurados", string, "Ok", "Fechar");
     return 1;
}
Poderia usar algo como isto no Comando


Re: Exibir players em dialogo - Crueliz0n - 09.07.2012

pawn Код:
if(!strcmp(cmdtext,"/procurados",true))
{
    string[512],name[MAX_PLAYER_NAME],count;
    for(new i; i < MAX_PLAYERS; ++i)
    {
        if(IsPlayerConnected(i) && procurado[i] != 0)
        {
            GetPlayerName(i, name, sizeof(name));
            format(string,sizeof(string), "%s [%i]", name,i);
            ShowPlayerDialog(playerid,1337, DIALOG_STYLE_MSGBOX, "• Lista de Procurados •",string, "FECHAR", "");
            count++;
        }
        if(count == 0)
        ShowPlayerDialog(playerid,1337, DIALOG_STYLE_MSGBOX, "• Lista de Procurados •","Nenhum Procurado", "FECHAR", "");
    }
    return 1;
}



Re: Exibir players em dialogo - [XPG]MarlonCS - 09.07.2012

Quote:
Originally Posted by BlackDonelly
Посмотреть сообщение
pawn Код:
if(!strcmp(cmdtext,"/procurados",true))
{
    string[512],name[MAX_PLAYER_NAME],count;
    for(new i; i < MAX_PLAYERS; ++i)
    {
        if(IsPlayerConnected(i) && procurado[i] != 0)
        {
            GetPlayerName(i, name, sizeof(name));
            format(string,sizeof(string), "%s [%i]", name,i);
            ShowPlayerDialog(playerid,1337, DIALOG_STYLE_MSGBOX, "• Lista de Procurados •",string, "FECHAR", "");
            count++;
        }
        if(count == 0)
        ShowPlayerDialog(playerid,1337, DIALOG_STYLE_MSGBOX, "• Lista de Procurados •","Nenhum Procurado", "FECHAR", "");
    }
    return 1;
}
Funciou muito bem... Porйm, sу exibe 1 player, nгo uma lista \=


Re: Exibir players em dialogo - [XPG]MarlonCS - 09.07.2012

ninguйm? \=


Re: Exibir players em dialogo - Crueliz0n - 09.07.2012

tente assim:
pawn Код:
if(!strcmp(cmdtext,"/procurados",true))
{
    new string[512],name[MAX_PLAYER_NAME],count;
    for(new i; i < MAX_PLAYERS; ++i)
    {
        if(IsPlayerConnected(i) && procurado[i] != 0)
        {
            GetPlayerName(i, name, sizeof(name));
            format(string,sizeof(string), "%s [%i]", name,i);
            count++;
        }
        ShowPlayerDialog(playerid,1337, DIALOG_STYLE_MSGBOX, "• Lista de Procurados •",string, "FECHAR", "");
        if(count == 0)
        ShowPlayerDialog(playerid,1337, DIALOG_STYLE_MSGBOX, "• Lista de Procurados •","Nenhum Procurado", "FECHAR", "");
    }
    return 1;
}



Re: Exibir players em dialogo - [XPG]MarlonCS - 09.07.2012

Quote:
Originally Posted by BlackDonelly
Посмотреть сообщение
tente assim:
pawn Код:
if(!strcmp(cmdtext,"/procurados",true))
{
    new string[512],name[MAX_PLAYER_NAME],count;
    for(new i; i < MAX_PLAYERS; ++i)
    {
        if(IsPlayerConnected(i) && procurado[i] != 0)
        {
            GetPlayerName(i, name, sizeof(name));
            format(string,sizeof(string), "%s [%i]", name,i);
            count++;
        }
        ShowPlayerDialog(playerid,1337, DIALOG_STYLE_MSGBOX, "• Lista de Procurados •",string, "FECHAR", "");
        if(count == 0)
        ShowPlayerDialog(playerid,1337, DIALOG_STYLE_MSGBOX, "• Lista de Procurados •","Nenhum Procurado", "FECHAR", "");
    }
    return 1;
}
Continua com problema \=


Re: Exibir players em dialogo - zSuYaNw - 09.07.2012

Quote:
Originally Posted by BlackDonelly
Посмотреть сообщение
tente assim:
pawn Код:
if(!strcmp(cmdtext,"/procurados",true))
{
    new string[512],name[MAX_PLAYER_NAME],count;
    for(new i; i < MAX_PLAYERS; ++i)
    {
        if(IsPlayerConnected(i) && procurado[i] != 0)
        {
            GetPlayerName(i, name, sizeof(name));
            format(string,sizeof(string), "%s [%i]", name,i);
            count++;
        }
        ShowPlayerDialog(playerid,1337, DIALOG_STYLE_MSGBOX, "• Lista de Procurados •",string, "FECHAR", "");
        if(count == 0)
        ShowPlayerDialog(playerid,1337, DIALOG_STYLE_MSGBOX, "• Lista de Procurados •","Nenhum Procurado", "FECHAR", "");
    }
    return 1;
}
Seu cуdigo irб exibir 500x o dialog.

pawn Код:
if(!strcmp(cmdtext, "/procurados", true))
    {
        new
            arm[500],
            Nome[24]
        ;
        for(new i, e = GetMaxPlayers(); i != e;++i)
        {
             if(procurado[i] > 0)
             {
                  GetPlayerName(i, Nome, sizeof(Nome));
                  strcat(arm, Nome);
             }
        }
        ShowPlayerDialog(playerid, 10, DIALOG_STYLE_LIST, "Procurados", arm, "Ok", "Fechar");
        return true;
    }



Re: Exibir players em dialogo - sanalex - 09.07.2012

Outro modo :

pawn Код:
if(!strcmp(cmdtext, "/procurados", true))
{
    new dialog[256], nome[MAX_PLAYER_NAME];
   
    foreach(Player, i)
    {
        if(GetPlayerWantedLevel(i) > 0)
        {
            GetPlayerName(i, nome, MAX_PLAYER_NAME);
            format(dialog, sizeof dialog, "%s%s (%i)", dialog, nome, GetPlayerWantedLevel(i));
        }
    }
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "PROCURADOS", dialog, "Ok", "Sair");
    return 1;
}



Re: Exibir players em dialogo - zSuYaNw - 09.07.2012

Quote:
Originally Posted by sanalex
Посмотреть сообщение
Outro modo :

pawn Код:
if(!strcmp(cmdtext, "/procurados", true))
{
    new dialog[256], nome[MAX_PLAYER_NAME];
   
    foreach(Player, i)
    {
        if(GetPlayerWantedLevel(i) > 0)
        {
            GetPlayerName(i, nome, MAX_PLAYER_NAME);
            format(dialog, sizeof dialog, "%s%s (%i)", dialog, nome, GetPlayerWantedLevel(i));
        }
    }
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "PROCURADOS", dialog, "Ok", "Sair");
    return 1;
}
Oque seu cуdigo faz?
pawn Код:
if(!strcmp(cmdtext, "/procurados", true))
{
    // Cria arrays
    new dialog[256], nome[MAX_PLAYER_NAME];

    // Faz um loooping de player(que estб errado pela ъltima atualizaзгo)
    foreach(Player, i)
    {
        // Verifica se o level de procurado й maior que 0
        if(GetPlayerWantedLevel(i) > 0)
        {
            // Pega o nome do player e armazena na variбvel nome.
            GetPlayerName(i, nome, MAX_PLAYER_NAME);
           
            // Formata a string, dialog com o nome do player e level de procurado e tambйm a prуpria dialog
            format(dialog, sizeof dialog, "%s%s (%i)", dialog, nome, GetPlayerWantedLevel(i));
        }
    }
   
    // Exibe oque estб armazenado na array "dialog".
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "PROCURADOS", dialog, "Ok", "Sair");
    return 1;
}


Ah, uma pequena correзгo em meu cуdigo:
pawn Код:
if(!strcmp(cmdtext, "/procurados", true))
    {
        #define sStatic::%0<%1> \
                    static %0[%1]; %0[0] = '\0'

        #define iStatic::<%0> static %0; %0 = 0

        sStatic::arm<500>;
        sStatic::Nome<24>;

        iStatic::<i>;
        iStatic::<e>;
       
       
        for(e = GetMaxPlayers(); i != e; ++i)
        {
             if(procurado[i] > 0)
             {
                  GetPlayerName(i, Nome, sizeof(Nome));
                  strcat(arm, Nome);
             }
        }
        ShowPlayerDialog(playerid, 10, DIALOG_STYLE_LIST, "Procurados", arm, "Ok", "Fechar");
        return true;
    }