[Ajuda] Exibir players em dialogo
#1

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.
Reply
#2

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
Reply
#3

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;
}
Reply
#4

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 \=
Reply
#5

ninguйm? \=
Reply
#6

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;
}
Reply
#7

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 \=
Reply
#8

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;
    }
Reply
#9

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;
}
Reply
#10

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;
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)