for loop question
#1

Hello,

I have 4 vehicles in the mysql database. And I want to let them display a dialog box. Now I have the following code:
Код:
        new string2[200];
        for(new i=0;i!=MAX_AUTOHAUS;i++)
        {
            if(IsPlayerInRangeOfPoint(playerid,3,AutoHaus[i][aX],AutoHaus[i][aY],AutoHaus[i][aZ]))
            {
		        for(new n = 0; n <sizeof(AutoHausAuto);n++)
		        {
                    if(n == 1)
                    {
                        format(string2,sizeof string2,"%s",CarName[AutoHausAuto[n][aAutoID] - 400]);
                    }
                    else
                    {
                        format(string2,sizeof string2,"%s\n%s",string2,CarName[AutoHausAuto[n][aAutoID] - 400]);
                    }
                }
			}
        }
        ShowPlayerDialog(playerid,DIALOG_AUTOHAUS,DIALOG_STYLE_LIST,"Autohaus",string2,"Weiter","");
However, he shows no code. But if I take a 0 everywhere instead of the one he shows only one vehicle.

Here's my remaining code:
Код:
enum AutoHausAA {
	aAutoID,
	aaID,
	aPreis,
	aBenzin,
	aBenzinArt,
	AutoHausID
}
new AutoHausAuto[MAX_AUTOHAUSAUTO][AutoHausAA];
Код:
public LoadAutoHausAutos()
{
    new rows, fields, content[MAX_PLAYER_NAME];
    cache_get_data(rows, fields);

    for(new i = 0; i != rows; i++)
	{
        cache_get_row(i, 0, content);
		AutoHausAuto[i][aaID] = strval(content);

        cache_get_row(i, 1, content);
		AutoHausAuto[i][aAutoID] = strval(content);
		cache_get_row(i, 2, content);
		AutoHausAuto[i][aPreis] = strval(content);
		cache_get_row(i, 3, content);
		AutoHausAuto[i][aBenzin] = strval(content);
		cache_get_row(i, 4, content);
		AutoHausAuto[i][aBenzinArt] = strval(content);
		cache_get_row(i, 5, content);
		AutoHausAuto[i][AutoHausID] = strval(content);
    }

    printf("AutoHausAutos: Es wurden %i AutoHausAutos geladen.", rows); //this is in german!
	return 1;
}
Reply
#2

Try this, but I'm not sure it will help

Код:
new string2[200];
        for(new i = 0;i != MAX_AUTOHAUS;i++) {
            if(IsPlayerInRangeOfPoint(playerid, 3, AutoHaus[i][aX], AutoHaus[i][aY], AutoHaus[i][aZ])) {
                for(new n = 0;n < sizeof(AutoHausAuto);n++) {
                    if (n == 1) {
                        format(string2, 200, "%s", CarName[AutoHausAuto[n][aAutoID] - 400]);
                    } else {
                        format(string2, 200, "%s\n%s", string2, CarName[AutoHausAuto[n][aAutoID] - 400]);
                    }
                }
            }
        }
        ShowPlayerDialog(playerid, DIALOG_AUTOHAUS, DIALOG_STYLE_LIST, "Autohaus", string2, "Weiter", "");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)