Quote:
Originally Posted by hamzajaved780
Confused about these arrays
Lets say i have a variable which stores a model id
Код:
Model[playerid][Slot][10]
now these are 10 variables for each player. Now i want to show the model ids to a player via your dialog except those which have "0" value. How could i do that ![Huh?](images/smilies/confused.gif) ? I am really confused...
|
You can do something like this:
pawn Код:
new var[10];
new var2[10];
new end;
for(new i = 0; i < 10; i++)
{
if(var[i] != 0)
{
for(new x = 0; x < 10; x++)
{
if(var2[x] == 0)
{
var2[x] = var[i];
end = (x + 1);
break;
}
}
}
}
Say
var is your player array and
var2 is a new array where the data will be sorted. You don't need to make it player array, because the dialog only requires models. So
end saves the last index and everything is done. This is one example of sorting, don't know if there is better method. You may download an include for sorting arrays, i have seen an include on sorting before.