Format by number
#1

How to set a format in one dialog by number of listitems.

Код:
if(businessVariables[xf][bType] == 1 && businessVariables[xf][bLoc] == 1) ls++;
if(businessVariables[xf][bType] == 2 && businessVariables[xf][bLoc] == 1) ls2++;
if(businessVariables[xf][bType] == 3 && businessVariables[xf][bLoc] == 1) ls3++;
if(businessVariables[xf][bType] == 4 && businessVariables[xf][bLoc] == 1) ls4++;
if(businessVariables[xf][bType] == 6 && businessVariables[xf][bLoc] == 1) ls5++;
if(businessVariables[xf][bType] == 7 && businessVariables[xf][bLoc] == 1) ls6++;
if(businessVariables[xf][bType] == 8 && businessVariables[xf][bLoc] == 1) ls7++;
if(businessVariables[xf][bType] == 9 && businessVariables[xf][bLoc] == 1) ls8++;
if(businessVariables[xf][bType] == 13 && businessVariables[xf][bLoc] == 1) ls9++;
if(businessVariables[xf][bType] == 14 && businessVariables[xf][bLoc] == 1) ls10++;
And I want to show for example:
10 businesses
1 business
not 1 Businesses if you know what I mean.

Код:
if(ls2 == 1)
{
    format(b, sizeof(b), "business");
}
if(ls2 > 1)
{
   format(b, sizeof(b), "businesses");
}
Something like this didn't work...
Reply
#2

pawn Код:
new businessnumber[10] = 0;
if(businessVariables[xf][bType] == 1 && businessVariables[xf][bLoc] == 1) businessnumber[0]++;
if(businessVariables[xf][bType] == 2 && businessVariables[xf][bLoc] == 1) businessnumber[1]++;
if(businessVariables[xf][bType] == 3 && businessVariables[xf][bLoc] == 1) businessnumber[2]++;
if(businessVariables[xf][bType] == 4 && businessVariables[xf][bLoc] == 1) businessnumber[3]++;
if(businessVariables[xf][bType] == 6 && businessVariables[xf][bLoc] == 1) businessnumber[4]++;
if(businessVariables[xf][bType] == 7 && businessVariables[xf][bLoc] == 1) businessnumber[5]++;
if(businessVariables[xf][bType] == 8 && businessVariables[xf][bLoc] == 1) businessnumber[6]++;
if(businessVariables[xf][bType] == 9 && businessVariables[xf][bLoc] == 1) businessnumber[7]++;
if(businessVariables[xf][bType] == 13 && businessVariables[xf][bLoc] == 1) businessnumber[8]++;
if(businessVariables[xf][bType] == 14 && businessVariables[xf][bLoc] == 1) businessnumber[9]++;
and to name it business or businesses:
pawn Код:
new b[128];
if(businessnumber[0] == 1) //checking if it's btype as you did in ls
{
    format(b, sizeof(b), "Business");
}
else
{
    format(b, sizeof(b), "Businesses");
}
Reply
#3

^Is like my old code, nothing changed... (this display in a dialog, so maybe I miss something).
Код:
format(list1, sizeof(list1), "24/7 Store (%d %s)\nClothing Store (%d %s)\nBar (%d %s)\nSex Shop (%d %s)\nGym (%d %s)\nRestaurant (%d %s)\nBank (%d %s)\nCNN (%d %s)\nGun Shop (%d %s)\nRent Car (%d %s)", n[0], b, n[1], b, n[2], b, n[3], b, n[4], b, n[5], b, n[6], b, n[7], b, n[8], b, n[9], b);
Reply
#4

Why didnt you say that from the begin?
well,You are using "b" for all of the businesses,which means that it will show in the dialog only businessnumber[9],You gotta have to change it and do it like this:
pawn Код:
new businessnumber[10] = 0;
if(businessVariables[xf][bType] == 1 && businessVariables[xf][bLoc] == 1) businessnumber[0]++;
if(businessVariables[xf][bType] == 2 && businessVariables[xf][bLoc] == 1) businessnumber[1]++;
if(businessVariables[xf][bType] == 3 && businessVariables[xf][bLoc] == 1) businessnumber[2]++;
if(businessVariables[xf][bType] == 4 && businessVariables[xf][bLoc] == 1) businessnumber[3]++;
if(businessVariables[xf][bType] == 6 && businessVariables[xf][bLoc] == 1) businessnumber[4]++;
if(businessVariables[xf][bType] == 7 && businessVariables[xf][bLoc] == 1) businessnumber[5]++;
if(businessVariables[xf][bType] == 8 && businessVariables[xf][bLoc] == 1) businessnumber[6]++;
if(businessVariables[xf][bType] == 9 && businessVariables[xf][bLoc] == 1) businessnumber[7]++;
if(businessVariables[xf][bType] == 13 && businessVariables[xf][bLoc] == 1) businessnumber[8]++;
if(businessVariables[xf][bType] == 14 && businessVariables[xf][bLoc] == 1) businessnumber[9]++;
and when checking:
pawn Код:
new b[28], b2[128], b3[128], b4[128], b5[128], b6[128], b7[128], b8[128], b9[128], b10[128];
if(businessnumber[0] == 1)
{
    format(b, sizeof(b), "Business");
}
else
{
    format(b, sizeof(b), "Businesses");
}
if(businessnumber[1] == 1)
{
    format(b2, sizeof(b2), "Business");
}
else
{
    format(b2, sizeof(b2), "Businesses");
}
if(businessnumber[2] == 1)
{
    format(b3, sizeof(b3), "Business");
}
else
{
    format(b3, sizeof(b3), "Businesses");
}
if(businessnumber[3] == 1)
{
    format(b4, sizeof(b4), "Business");
}
else
{
    format(b4, sizeof(b4), "Businesses");
}
if(businessnumber[4] == 1)
{
    format(b5, sizeof(b5), "Business");
}
else
{
    format(b5, sizeof(b5), "Businesses");
}
if(businessnumber[5] == 1)
{
    format(b6, sizeof(b6), "Business");
}
else
{
    format(b6, sizeof(b6), "Businesses");
}
if(businessnumber[6] == 1)
{
    format(b7, sizeof(b7), "Business");
}
else
{
    format(b7, sizeof(b7), "Businesses");
}
if(businessnumber[7] == 1)
{
    format(b8, sizeof(b8), "Business");
}
else
{
    format(b8, sizeof(b8), "Businesses");
}
if(businessnumber[8] == 1)
{
    format(b9, sizeof(b9), "Business");
}
else
{
    format(b9, sizeof(b9), "Businesses");
}
if(businessnumber[9] == 1)
{
    format(b10, sizeof(b10), "Business");
}
else
{
    format(b10, sizeof(b10), "Businesses");
}
and when showing dialog:
pawn Код:
format(list1, sizeof(list1), "24/7 Store (%d %s)\nClothing Store (%d %s)\nBar (%d %s)\nSex Shop (%d %s)\nGym (%d %s)\nRestaurant (%d %s)\nBank (%d %s)\nCNN (%d %s)\nGun Shop (%d %s)\nRent Car (%d %s)", n[0], b1, n[1], b2, n[2], b3, n[3], b4, n[4], b5, n[5], b6, n[6], b7, n[7], b8, n[8], b9, n[9], b10);
Reply
#5

Thank you for you help +rep.
Reply
#6

@R0:
Ah! What do you do there?
PHP код:
new b[10][11],i;
for(;
i<10;i++)
{
    if(
businessnumber[i] == 1)strcat(b[i],"Business");
    else if(
businessnumber[i] > 1)strcat(b[i],"Businesses");

It's short and good for a better view.

Mencent
Reply
#7

Quote:
Originally Posted by Mencent
Посмотреть сообщение
@R0:
Ah! What do you do there?
PHP код:
new b[10][11],i;
for(;
i<10;i++)
{
    if(
businessnumber[i] == 1)strcat(b[i],"Business");
    else if(
businessnumber[i] > 1)strcat(b[i],"Businesses");

It's short and good for a better view.

Mencent
This is great , Thanks
Reply


Forum Jump:


Users browsing this thread: