SA-MP Forums Archive
Wanted level in dialog - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Wanted level in dialog (/showthread.php?tid=284537)



Wanted level in dialog - Wesley221 - 19.09.2011

Hey guys,

I wanna know how to show all the names in a list (dialog in this case), like this:
Код:
Name 1 (wanted level)
Name 2 (wanted level)
Name 3 (wanted level)
Name 39393938272717119 (wanted level)
I dont really got a clue, but i made a little snippet, which should work, but wont show the names in the dialog (i think).
pawn Код:
COMMAND:checkwanted(playerid, params[])
{
    new dialog[256], name[24];
    for( new i = 0; i < MAX_PLAYERS; i ++ )
    {
        if( GetPlayerWantedLevel( i ) >= 2 )
        {
            GetPlayerName( i, name, 24);
            format( dialog, sizeof dialog, "%s (%i)", name, GetPlayerWantedLevel( i ) );
        }
    }
    ShowPlayerDialog( playerid, 1, DIALOG_STYLE_LIST, "Wanted levels", dialog, "Ok", "");
    return 1;
}
~Wesley


Re: Wanted level in dialog - steki. - 19.09.2011

You'll have to create a secondary string to strcat to the dialog. Otherwise the dialog string would be overwritten at every loop course.


Re: Wanted level in dialog - Xyrex - 19.09.2011

pawn Код:
COMMAND:checkwanted(playerid, params[])
{
    new dialog[256], string[40], name[24];
    format(dialog, sizeof(dialog), "");
    for( new i = 0; i < MAX_PLAYERS; i ++ )
    {
        if( GetPlayerWantedLevel( i ) >= 2 )
        {
            GetPlayerName( i, name, 24);
            format( string, sizeof (string), "%s (%i)", name, GetPlayerWantedLevel( i ) );
            format(dialog, sizeof(dialog), "%s\n%s", dialog, string);
        }
    }
    ShowPlayerDialog( playerid, 1, DIALOG_STYLE_LIST, "Wanted levels", dialog, "Ok", "");
    return 1;
}



Re: Wanted level in dialog - Virtual1ty - 19.09.2011

There's actually no need for a second string ! Waste of memory.
Something like this should do the trick (checks if a player has any wanted level):

pawn Код:
COMMAND:checkwanted(playerid, params[])
{
    new dialog[256], name[MAX_PLAYER_NAME];
   
    foreach(Player, i)
    {
        if(GetPlayerWantedLevel(i) > 0)
        {
            GetPlayerName(i, name, MAX_PLAYER_NAME);
            format(dialog, sizeof dialog, "%s%s (%i)", dialog, name, GetPlayerWantedLevel(i));
        }
    }
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Wanted levels", dialog, "Ok", "");
    return 1;
}



Re: Wanted level in dialog - Wesley221 - 19.09.2011

Quote:
Originally Posted by Luнs Miki
Посмотреть сообщение
You'll have to create a secondary string to strcat to the dialog. Otherwise the dialog string would be overwritten at every loop course.
Thanks i will use this, good thinking PlayerInfo[Luнs Miki][pReputation]++;

I dont mind an extra variable which uses a little bit of memory.