Warning: unreachable code.
#1

I made this code for check if is any empty slot used. I made one stock for enter to Database and look if there is any column with the ID, if is empty it break the loop and return the value that found, but it send to me one warning.

I use the break for stop the loop if found one.

pawn Код:
stock ComprobarSlot(SlotLibre)
{
for(new i =0; i < MAX_VEHICLES; i++)
    {
    new solicitud[254];
    format(solicitud, sizeof(solicitud), "SELECT * FROM `vehiculos` WHERE %d");
    mysql_query(mysql, solicitud);
    new columnas, filas;
    cache_get_data(columnas, filas);
    if(!columnas)
    {
    break;
    return SlotLibre;
    }
    }
    return 1;
}
Reply
#2

Try return 0; once
Код:
stock ComprobarSlot(SlotLibre)
{
for(new i =0; i < MAX_VEHICLES; i++)
    {
    new solicitud[254];
    format(solicitud, sizeof(solicitud), "SELECT * FROM `vehiculos` WHERE %d");
    mysql_query(mysql, solicitud);
    new columnas, filas;
    cache_get_data(columnas, filas);
    if(!columnas)
    {
    break;
    return SlotLibre;
    }
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by mjay768
Посмотреть сообщение
Try return 0; once
Код:
stock ComprobarSlot(SlotLibre)
{
for(new i =0; i < MAX_VEHICLES; i++)
    {
    new solicitud[254];
    format(solicitud, sizeof(solicitud), "SELECT * FROM `vehiculos` WHERE %d");
    mysql_query(mysql, solicitud);
    new columnas, filas;
    cache_get_data(columnas, filas);
    if(!columnas)
    {
    break;
    return SlotLibre;
    }
    }
    return 1;
}
Don't work, i want to get the empty slot with this stock, їany idea?
Reply
#4

Don't use "mysql_query" in loop, it's very slow.
Take mysql_pquery, which uses the multi-threading

See : MySQL R39-2 and his wiki
Reply
#5

Quote:
Originally Posted by Dutheil
Посмотреть сообщение
Don't use "mysql_query" in loop, it's very slow.
Take mysql_pquery, which uses the multi-threading

See : MySQL R39-2 and his wiki
+ Create the variables outside the loop, so they don't get recreated each time.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)