For loop "Crash"?
#1

Basically, when creating the for loop to load the businesses it loads the first record and then stops completely.

Here is the code:

pawn Код:
stock loadbusiness()
{
    new Query[500];
    format(Query, sizeof(Query), "SELECT * FROM `businessinfo`");
    mysql_query(Query);
    mysql_store_result();
    for(new i = 1; i != mysql_num_rows(); i++)
    {
        if(i <= mysql_num_rows())
        {
            LoadBusinessInfo(i);
            format(Query, sizeof(Query), "SELECT * FROM `businessinfo` WHERE `bid` = %d", i);
            businesspickup[i] = CreatePickup(1272, 1, BVar[businessid[i]][bpickupx], BVar[businessid[i]][bpickupy], BVar[businessid[i]][bpickupz], 0);
            print(Query);
            currbusiness++;
        }
    }
    print("Buinesses Loaded");
    return 1;
}
Any help would be appreciated.
Reply
#2

try
replace
pawn Код:
for(new i = 1; i != mysql_num_rows(); i++)
to
pawn Код:
for(new i = 1; i < mysql_num_rows(); i++)
Reply
#3

pawn Код:
stock loadbusiness()
{
    new Query[500];
    format(Query, sizeof(Query), "SELECT * FROM `businessinfo`");
    mysql_query(Query);
    mysql_store_result();
    for(new i = 1; i < mysql_num_rows(); i++)
    {
        if(i <= mysql_num_rows())
        {
            format(Query, sizeof(Query), "SELECT * FROM `businessinfo` WHERE `bid` = %d", i);
            print(Query);
            LoadBusinessInfo(i);
            businesspickup[i] = CreatePickup(1272, 1, BVar[businessid[i]][bpickupx], BVar[businessid[i]][bpickupy], BVar[businessid[i]][bpickupz], 0);
            currbusiness++;
        }
    }
    print("Buinesses Loaded");
}
This is the script now, however it doesn't actually loop, it just does it once and then doesn't create the pickup like it used to.

This is the console log:

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)