Loop + dialog + if statement, good idea? - 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: Loop + dialog + if statement, good idea? (
/showthread.php?tid=510092)
Loop + dialog + if statement, good idea? -
Brandon_More - 29.04.2014
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?
Re: Loop + dialog + if statement, good idea? -
Ada32 - 29.04.2014
list item has ids so..switch(listitem) case 0: , blah
Re: Loop + dialog + if statement, good idea? -
RajatPawar - 29.04.2014
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.
Re: Loop + dialog + if statement, good idea? -
Brandon_More - 29.04.2014
I want it to gather the ID I selected.. If I use
it will select the listID.. not the ID.