Loop and dialogs
#1

I can't figure out what I have to change to make this code do the right thing, so what it's supposed to do is to list down the male names under "Male Names" and female names under "Female Names" the picture below code is result, for some reason there's something messy :/ - It shows double male names and there's a huge blank spot at female names, but under those everything is fine? (see picture) sooo how can I fix that?

Код:
showNameSuggestions(playerid)  {
	new msg[128];
	new female[128];
	new male[128];
	dialogstr[0] = 0;
	strcat(dialogstr,"Male Names\tFemale Names\n",sizeof(dialogstr));
	for(new i=0;i<sizeof(NameSuggestions); i++) {
		if(NameSuggestions[i][ENameSugID] == 1) {
			format(male,sizeof(male), "%s",NameSuggestions[i][ENameSug]);
		} else if(NameSuggestions[i][ENameSugID] == 2) {
			format(female,sizeof(female), "%s",NameSuggestions[i][ENameSug]);
		}
		format(msg,sizeof(msg), "%s\t%s\n",male,female);
		strcat(dialogstr,msg,sizeof(dialogstr));
	}
	ShowPlayerDialog(playerid, DIALOG_NAME, DIALOG_STYLE_TABLIST_HEADERS, "Suggested Names", dialogstr, "Choose!","Quit");
}
In case you need this part of code:
Код:
new NameSuggestions[][ENameSuggestions] = {
	{"MaleNameEX",1},
	{"MaleNameEX",1},
	{"MaleNameEX",1},
	{"MaleNameEX",1},
	{"MaleNameEX",1},
	{"MaleNameEX",1},
	{"MaleNameEX",1},
	{"FemaleNameEX",2},
	{"FemaleNameEX",2},
	{"FemaleNameEX",2},
	{"FemaleNameEX",2},
	{"FemaleNameEX",2},
	{"FemaleNameEX",2},
	{"FemaleNameEX",2}
};
This is the result:
Reply
#2

Watch out, while it loops through the first seven names female is an empty string. On the other hand, when it arrives to the 8th row, name contains "MaleNameEX". Say thank you to this for the result you got:
PHP код:
format(msgsizeof(msg), "%s\t%s\n"malefemale);
strcat(dialogstrmsgsizeof(dialogstr)); 
Give a try to this:
PHP код:
new names[3][2][24] = { // 3 rows, 2 names per row, 24 is the max. length a name can have
    
{"male1""female1"},
    {
"male2""female2"},
    {
"male3""female3"},
    {
"male4"""// you can skip a name, don't skip a male name 'cause you'll get wrong format in the dialog.
};
/* showNameSuggestions */
dialogstr[0] = EOS;
strcat(dialogstr"Male Names\tFemale Names"sizeof(dialogstr));
for(new 
0sizeof(names); x++)
{
    
format(dialogstr"%s\n%s\t%s"dialogstrnames[x][0], names[x][1]);
}
ShowPlayerDialog(playerididstyle"title"dialogstr"ok","bye"); 
Good luck with it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)