Loop error? Pickups
#1

pawn Код:
public LoadBusiness()
{
    new rows, fields;
    cache_get_data(rows, fields);
    if(rows)
    {
        for(new i = 0; i < rows; i++)
        {
                // Loading all of the stuff from the database, all fine.

            // Just incase I reload the whole business
            DestroyDynamicCP(BusinessInfo[i][bCP]);
            DestroyDynamic3DTextLabel(BusinessInfo[i][bText]);

                        // Problems here
            new string[94];
            if(strcmp(BusinessInfo[i][bOwner], "None", true, 0))
            {
                format(string, sizeof(string),
                "Name: %s",
                BusinessInfo[i][bName]);
            }
            else
            {
                format(string, sizeof(string),
                "Name: %s\n\
                Price: %d"
,
                BusinessInfo[i][bName],
                BusinessInfo[i][bPrice]);
            }

            BusinessInfo[i][bCP] = CreateDynamicCP(BusinessInfo[i][bEnterX], BusinessInfo[i][bEnterY], BusinessInfo[i][bEnterZ], 1);
            BusinessInfo[i][bText] = CreateDynamic3DTextLabel(string, COLOR_YELLOW, BusinessInfo[i][bEnterX], BusinessInfo[i][bEnterY], BusinessInfo[i][bEnterZ], 5.0);
        }
                // Problems end here
        printf("Businesses Loaded: %d", rows), gBusiness = rows;       
    }
    return 1;
}
They spawn but only the first ever created spawns.
Reply
#2

Where are you using functions for get the query content?

cache_get_row.....
Reply
#3

Quote:
Originally Posted by iJumbo
Посмотреть сообщение
Where are you using functions for get the query content?

cache_get_row.....
Like I said in the loop.
Reply
#4

Why don't paste? maybe erron in there..
Reply
#5

How can there been an error in the loading? It all loads, I've checked it.

Buh, if you insist:

pawn Код:
new bizName[64], bizOwner[MAX_PLAYER_NAME];
            BusinessInfo[i][bID] = cache_get_row_int(0, 0);
            cache_get_row(0, 1, bizName), BusinessInfo[i][bName] = bizName;
            cache_get_row(0, 2, bizOwner), BusinessInfo[i][bOwner] = bizOwner;
            BusinessInfo[i][bPrice] = cache_get_row_int(0, 3);
            BusinessInfo[i][bType] = cache_get_row_int(0, 4);
            BusinessInfo[i][bMoney] = cache_get_row_int(0, 5);
            BusinessInfo[i][bRobbed] = cache_get_row_int(0, 6);
            BusinessInfo[i][bRobbedTimer] = cache_get_row_int(0, 7);
            BusinessInfo[i][bEnterX] = cache_get_row_float(0, 8);
            BusinessInfo[i][bEnterY] = cache_get_row_float(0, 9);
            BusinessInfo[i][bEnterZ] = cache_get_row_float(0, 10);
            BusinessInfo[i][bExitX] = cache_get_row_float(0, 11);
            BusinessInfo[i][bExitY] = cache_get_row_float(0, 12);
            BusinessInfo[i][bExitZ] = cache_get_row_float(0, 13);
            BusinessInfo[i][bInt] = cache_get_row_int(0, 14);
Reply
#6

Here you fail ..

the frist param of cache_get_row...( is the row.. so remove 0 and put i (the loop var "i")
so you will get params for every row..
Reply
#7

Yep, I should have doubled checked my last script where I converted the r6 to R7, that one worked, but I did add the (i, blah). Thanks for your help.

Silly mistakes that I make when scripting.

I'm going to faceplant myself plenty of times, don't worry.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)