Warning: unreachable code. - 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: Warning: unreachable code. (
/showthread.php?tid=546741)
Warning: unreachable code. -
xHanks - 17.11.2014
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;
}
Re: Warning: unreachable code. -
mjay768 - 17.11.2014
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;
}
Respuesta: Re: Warning: unreachable code. -
xHanks - 17.11.2014
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?
Re : Warning: unreachable code. -
Dutheil - 17.11.2014
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
Re: Re : Warning: unreachable code. -
Kyance - 17.11.2014
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.