Loop + dialog + if statement, good idea?
#1

Well, been experimenting more :/ Anyway, I was wondering? Is it a good idea to use a loop & if statement inside dialogs?

FOr example:

pawn Код:
new BuildString[128], RealString[528];
PLoop(p)
{
    if(P_INFO[p][PAdmin] >= 1)
    {
        format(BuildString, sizeof(BuildString), " - %s(%d) is a level %d admin.", FuckUnderscore(PlayerName(playerid)), p, P_INFO[p][PAdmin]);
        strcat(RealString, BuildString);
    }
}
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_LIST, "Admins online, click on mesage them", RealString, "MSG", "GTFO");
How would I be able to add a response for this?
Reply
#2

list item has ids so..switch(listitem) case 0: , blah
Reply
#3

It's all good. The only minor (and not absolutely necessary) improvement I would recommend is using foreach. Also, inserting '\n' at the end of each format. Thirdly, you don't need two strings. You can just use one string like -

pawn Код:
static RealString[528];
PLoop(p)
{
    if(P_INFO[p][PAdmin] >= 1)
    {
        format(RealString, sizeof(RealString), "%s - %s(%d) is a level %d admin.", RealString, FuckUnderscore(PlayerName(playerid)), p, P_INFO[p][PAdmin]);
    }
}
As for the response, you can maintain a list of the returned IDs in an array, then use it like - GetName(MaintainedIDRecord[listitem]) or something.
Reply
#4

I want it to gather the ID I selected.. If I use

Код:
listitem
it will select the listID.. not the ID.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)