Not loading all variables
#1

I got this code and it isnt loading all the values from the mysql database. What is wrong?
pawn Код:
forward LoadVehicles();
public LoadVehicles()
{
    new Query[500];
    for(new i; i < MAX_VEHICLES; i++) // Makes an loop so all vehicles get loaded.
    {
        format(Query, sizeof(Query), "SELECT * FROM vehicles WHERE id= %d", i);
        mysql_query(Query); // Querys the "Query" Variable.
        mysql_store_result(); // Stores the result from Query
        if(mysql_num_rows()) // Checks if theres anyrow.
        if(mysql_fetch_row(Query)) // Splits the row
        {
            sscanf(Query, "p<|>e<iiiiffffs[24]s[24]iiiiiii>", vehicleinfo[i]);
            printf("type = %d", vehicleinfo[i][type]);
            if(vehicleinfo[i][type] != 1)
            {
                new globalkey;
                globalkey = CreateVehicle(vehicleinfo[i][Model],vehicleinfo[i][x],vehicleinfo[i][y],vehicleinfo[i][z],vehicleinfo[i][a],vehicleinfo[i][Color1],vehicleinfo[i][Color2], 60*10000);
                printf("query: %s", Query);
                key[globalkey] = vehicleinfo[i][id];
                new engine,lights,alarm,doors,bonnet,boot,objective;
                GetVehicleParamsEx(globalkey,engine,lights,alarm,doors,bonnet,boot,objective);
                SetVehicleParamsEx(globalkey,0,lights,alarm,doors,bonnet,boot,objective);
                vehicleinfo[i][Engine] = 0;
               
            }
        }
    }
}
enum vInfo()
{
    id,
    Model,
    Color1,
    Color2,
    Float:x,
    Float:y,
    Float:z,
    Float:a,
    Name[MAX_PLAYER_NAME],
    Owner[MAX_PLAYER_NAME],
    Lock,
    Parked,
    Spawned,
    Destroyed,
    Licenses,
    Engine,
    type,
}
new vehicleinfo[MAX_VEHICLES][vInfo];
Reply
#2

+rep for who helps me.
Reply
#3

pawn Код:
if(!mysql_num_rows()) continue; // Checks if theres anyrow.
Reply
#4

Yes there are 4 rows.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)