SA-MP Forums Archive
Loop error? Pickups - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Loop error? Pickups (/showthread.php?tid=456687)



Loop error? Pickups - Riddy - 07.08.2013

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.


Re: Loop error? Pickups - iJumbo - 07.08.2013

Where are you using functions for get the query content?

cache_get_row.....


Re: Loop error? Pickups - Riddy - 07.08.2013

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

cache_get_row.....
Like I said in the loop.


Re: Loop error? Pickups - iJumbo - 07.08.2013

Why don't paste? maybe erron in there..


Re: Loop error? Pickups - Riddy - 07.08.2013

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);



Re: Loop error? Pickups - iJumbo - 07.08.2013

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..


Re: Loop error? Pickups - Riddy - 07.08.2013

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.