[HELP] Problem with "for" - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] Problem with "for" (
/showthread.php?tid=203558)
[HELP] Problem with "for" -
mark.18 - 27.12.2010
Hi, i have got a problem with a for, the for loads the car system. The for(i have been trying with "while" but no works so far). The for is this i think is good
Код:
forward CargarSistemaVeh();
public CargarSistemaVeh()
{
for (new c=1; c<=MAX_VEHICLES;)
// new c;
// while (c != MAX_VEHICLES) Doesnґt work with while
{
CargarCoche©;
//print("Cargando Coche");
//printf("ID: %d Cargado |", c);
c++;
}
printf("Vehiculos Cargados");//
}
This works very well i think, but the problem is in "CargarCoche©" fuction when in the DataBase skips a id, for example when you delete a car. When this happens and "CargarCoche" load a invalid id, the "for" of CargarSistemaVeh() ends and end all Ongamemodeinit and Doesnґt load next cars
Код:
forward CargarCoche(carid);
public CargarCoche(carid)
{
new sql[100];
new f[44][44];
new row[256];
format(sql, sizeof(sql), "SELECT * FROM Vehiculos WHERE IDVEH=%d", carid);
if(samp_mysql_query(sql))// la consulta devuelve 1 carga el coche
{
samp_mysql_query(sql);// tambien he probado sin repetir esto, osea dejando solo la del if
samp_mysql_store_result();
samp_mysql_fetch_row(row);
split(row,f,'|');
//here loads the vehicle well and loads data of vehicle
}
/* else{
//query return 0 Doesnґt work
}*/
}
Sorry if my post is confusing.