Getting spammed
#1

Wny ideas this is spamming my mysql_log.log?

and if i got 1 (or more) vehicles it sais "Loaded Vehicles: 500 vehicles", who is not true
but if i have 0 vehicles and then it sais "Loaded Vehicles: 0 vehicles" and its correct
pawn Код:
stock LoadVehicles()
{
    new string[44], c, row[85];
    for(new v; v < MAX_OWNED_VEHICLES; v ++)
    {
        format(string, sizeof(string), "SELECT * FROM `vehs` WHERE `vehid` = '%d'", v);
        mysql_query(string);
        mysql_store_result();
        if(mysql_num_rows())
        {
            if(mysql_fetch_row_format(row, "|"))
            {
                c ++;
                sscanf(row, "p<|>ds[24]ffffdddd", VehicleInfo[v][vid], VehicleInfo[v][Owner],VehicleInfo[v][x],VehicleInfo[v][y],VehicleInfo[v][z],VehicleInfo[v][a],VehicleInfo[v][mid],VehicleInfo[v][col1],VehicleInfo[v][col2],VehicleInfo[v][pc]);
                CreateVehicle(VehicleInfo[v][mid], VehicleInfo[v][x], VehicleInfo[v][y], VehicleInfo[v][z], VehicleInfo[v][a], VehicleInfo[v][col1], VehicleInfo[v][col2], -1);
            }
        }
        mysql_free_result();
    }
    printf("Loaded Vehicles: %d vehicles", c);
    return 1;
}
Reply
#2

pawn Код:
for(new v; v < MAX_OWNED_VEHICLES; v ++)
MAX_OWNED_VEHICLES is defined as 500?

instead of looping, just select the entire table and get information from their, its faster and less buggy.
Reply
#3

What is the value of MAX_OWNED_VEHICLES? Your query command will execute that many times and record 2 lines in the log. You will also have an additional 2 lines recorded in the log for the mysql_store_result, and another 2 for mysql_num_rows. That's already 6 lines recorded in the log for every iteration in your FOR loop.
If your mysql_num_rows check passes, you will then have 2 more lines recorded in your log for every successful mysql_fetch_row_format command (ie, if it finds 4 rows(database records) with the matching criteria for your query, you will have 8 lines in your log to display this).
It all adds up very quickly!
As for the "Loaded Vehicles: 500 vehicles", I can't be too sure without knowing the contents of your database, and the value of MAX_OWNED_VEHICLES.
Reply
#4

Quote:
Originally Posted by Donya
Посмотреть сообщение
pawn Код:
for(new v; v < MAX_OWNED_VEHICLES; v ++)
MAX_OWNED_VEHICLES is defined as 500?

instead of looping, just select the entire table and get information from their, its faster and less buggy.
Yes it is defined as 500, and how do i select the entire table? Can you give me a example?
Reply
#5

pawn Код:
stock LoadVehicles()
{
    new c, v, Query[85];
    mysql_query("SELECT * FROM `vehs` ORDER BY `vehs`.`vehid` ASC");
    mysql_store_result();
    if(mysql_num_rows() > 0)
    {
        while(mysql_fetch_row(Query))
        {
            c ++;
            sscanf(Query, "p<|>d", v);
            sscanf(Query, "p<|>ds[24]ffffdddd", VehicleInfo[v][vid], VehicleInfo[v][Owner],VehicleInfo[v][x],VehicleInfo[v][y],VehicleInfo[v][z],VehicleInfo[v][a],VehicleInfo[v][mid],VehicleInfo[v][col1],VehicleInfo[v][col2],VehicleInfo[v][pc]);
            CreateVehicle(VehicleInfo[v][mid], VehicleInfo[v][x], VehicleInfo[v][y], VehicleInfo[v][z], VehicleInfo[v][a], VehicleInfo[v][col1], VehicleInfo[v][col2], -1);
        }
    }
    mysql_free_result();
    printf("Loaded Vehicles: %d vehicles", c);
    return 1;
}
Reply
#6

Thanks, Works
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)