2021-01-23, 02:18 AM
(2021-01-22, 08:44 PM)Markski Wrote:(2021-01-21, 11:54 PM)RhaegarX Wrote: Is there any place where I can find some explanation about the loop in the enum?? Because I would only loop the members' positions
It's simply to loop through every item in the enum, and you do this by using it's size as the upper limit.
The way to traditionally do this is:
Code:for (new i = 0; i < sizeof(enumName); i)
However, because in this case the enum contains a lot of irrelevant data, you want to start on the position of the enum where the members are. In your enum, it looks like the members start at the 32th position, or 31 counting from 0.
I think this should work:
Code:for (new i = 31; i < sizeof(oInfo); i) {
format(string, sizeof(string), "Member %i: %s\n", i-30; OrgInfo[org][oInfo:i]);
strcat(membersList, string);
}
ShowPlayerDialog(playerid, DIALOG_ORG_BACK, DIALOG_STYLE_TABLIST_HEADERS, "Membros da Organiza??o", membersList, "Voltar", "Fechar");
However, I cannot test it right now.
Note that using 31 as a "magic number" to start the loop looks dirty, and that's because it is. A better solution would be to store the members in another way. A slightly more elegant way to handle it would be perhaps to have a Members[MAX_GROUP_MEMBERS][MAX_PLAYER_NAME] 3d array defined in the enum so you can cleanly loop from 0 to MAX_GROUP_MEMBERS instead. Realistically, loading them right off the database might be the "cleanest" way of them all.
I tried it that way and returned the following error:
PHP Code:
error: 039: constant symbol has no size