Wanted list
#1

I made i wanted list and placed it into a MSGBOX (dialog), it works and all but when i type /wanted in game, it just shows the name of the last player that i set wanted to.

So if A, B and C are wanted, it only shows C.

pawn Код:
COMMAND:wanted(playerid, params[])
{
    new count, namestr[64];
    for(new i; i < MAX_PLAYERS; i++)
    {
    if(!IsPlayerConnected(i) || i == INVALID_PLAYER_ID)continue;
    if(GetPlayerWantedLevel(i)!=0)
    {
    count++;
    GetPlayerName(i,namestr,MAX_PLAYER_NAME);
    format(namestr,64,"%s level: %d",namestr,GetPlayerWantedLevel(i));
    ShowPlayerDialog(playerid,500, DIALOG_STYLE_MSGBOX, "Wanted List.",namestr,"Ok", "Cancel");
    }
    }
    if(count == 0)return SendClientMessage(playerid,White,"There are no wanted Players");
    return 1;
}
Reply
#2

that's because you're getting the players name and then showing it in a dialog instead of getting all the names and putting them in a string and then putting that into a dialog

pawn Код:
COMMAND:wanted(playerid, params[])
{
    new count, namestr[MAX_PLAYER_NAME], string[128];//64 is too much since the max length of a name is like ~20
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(GetPlayerWantedLevel(i)!=0)
            {
                count++;
                GetPlayerName(i,namestr,MAX_PLAYER_NAME);
                if(!strlen(string))
                {
                    format(string,sizeof(string),"%s level: %d",namestr,GetPlayerWantedLevel(i));
                }
                else
                {
                    format(string,sizeof(string),"\n%s level: %d",namestr,GetPlayerWantedLevel(i));    
                }
            }
        }
    }
//also you'd use ShowPlayerDialog outside of the loop, just after it's finished
    ShowPlayerDialog(playerid,500, DIALOG_STYLE_MSGBOX, "Wanted List.",string,"Ok", "Cancel");
    if(count == 0)return SendClientMessage(playerid,White,"There are no wanted Players");
    return 1;
}
Reply
#3

Still shows one player in the MSGBOX.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)