String loop in dialog
#1

pawn Код:
new string[512];
for(new model=508;model<471;model++)
{
     format(string, 512, "%s"#orange"%s\n",string,VehicleNames[model-400]);
}
ShowPlayerDialog(playerid, ..., "Header", string, "Buy", "Close");
I tried to loop throught vehicles model ID 508 to 471 and show their names, but it dosen't work :-/
Reply
#2

This should fix it
pawn Код:
new string[512];
for(new model=508;model<471;model++)
{
     format(string, 512, "%s"#orange"%s\n",string,VehicleNames[model-400]);
}
ShowPlayerDialog(playerid, ..., "Header", string, "Buy", "Close");
Reply
#3

This is the same code
Reply
#4

Sort of makes sense that it does not work. What you're doing is starting the loop with model at value 508, then you increment it until it is smaller than 471. But guess what, that can't work.

What you need to do is figure out what the loop should look like, and from the small snippet you posted, you should probably loop from 0 to sizeof(VehicleNames), that will cover all vehicle names. To get the ID of the vehicle, you then have to add 400 to it.

Also, don't use format for strings as large as this, try strcat instead.
Reply
#5

Omg AndreT, thank you i didn't see, I wanted to start with 471 and stop on 508... Now I am ashamed
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)