No cars loaded - Mysql
#1

Hello and Merry Christmas,

I happen to have a problem where cars do not load properly ...

OnGameModeInit:

Код:
mysql_tquery(mysql, "SELECT * FROM autos", "CargarAutos", "");
And finally the function ...

Код:
funcion:CargarAutos()
{
	new index = 0;
    new rows = cache_get_row_count();
    for (new i = 0; i != rows; i++)
    {
        if(i == 953) break;
        for(new slot = 1; slot != 4; slot++) vehTrunkCounter[i] = 0;
        jAutos[i][vModelo] = cache_get_field_content_int(i, "vModelo");
        jAutos[i][vFaccion] = cache_get_field_content_int(i, "vFaccion");
		jAutos[i][vPosX] = cache_get_field_content_float(i, "vPosX");
		jAutos[i][vPosY] = cache_get_field_content_float(i, "vPosY");
		jAutos[i][vPosZ] = cache_get_field_content_float(i, "vPosZ");
		jAutos[i][vPosA] = cache_get_field_content_float(i, "vPosA");
		jAutos[i][vColor1] = cache_get_field_content_int(i, "vColor1");
		jAutos[i][vColor2] = cache_get_field_content_int(i, "vColor2");
		jAutos[i][vRespawn] = cache_get_field_content_int(i, "vRespawn");
		jAutos[i][vGasolina] = cache_get_field_content_int(i, "vGasolina");
	    jAutos[i][vMapa] = cache_get_field_content_int(i, "vMapa");
	    jAutos[i][vRadio] = cache_get_field_content_int(i, "vRadio");
	    jAutos[i][vBombas] = cache_get_field_content_int(i, "vBombas");
	    jAutos[i][vMedicinas] = cache_get_field_content_int(i, "vMedicinas");
	    jAutos[i][vBotiquines] = cache_get_field_content_int(i, "vBotiquines");
	    jAutos[i][vComida] = cache_get_field_content_int(i, "vComida");
	 	jAutos[i][vVendas] = cache_get_field_content_int(i, "vVendas");
	    jAutos[i][vBengalas] = cache_get_field_content_int(i, "vBengalas");
	    jAutos[i][vGanzuas] = cache_get_field_content_int(i, "vGanzuas");
	    jAutos[i][vDrogas] = cache_get_field_content_int(i, "vDrogas");
	    jAutos[i][vPalos] = cache_get_field_content_int(i, "vPalos");
	    jAutos[i][vFosforos] = cache_get_field_content_int(i, "vFosforos");
	    jAutos[i][vBaterias] = cache_get_field_content_int(i, "vBaterias");
	    jAutos[i][vAgua] = cache_get_field_content_int(i, "vAgua");
	    jAutos[i][vCarneFresca] = cache_get_field_content_int(i, "vCarnefresca");
	    jAutos[i][vLata] = cache_get_field_content_int(i, "vLata");
	    jAutos[i][vLataGasolina] = cache_get_field_content_int(i, "vLataGasolina");
	    vehTrunk[i][1] = cache_get_field_content_int(i, "vArma1");
	    vehTrunk[i][2] = cache_get_field_content_int(i, "vArma2");
	    vehTrunk[i][3] = cache_get_field_content_int(i, "vArma3");
	    vehTrunkAmmo[i][1] = cache_get_field_content_int(i, "vBalas1");
	    vehTrunkAmmo[i][2] = cache_get_field_content_int(i, "vBalas2");
	    vehTrunkAmmo[i][3] = cache_get_field_content_int(i, "vBalas3");
	    vehTrunkArmour[i] = cache_get_field_content_float(i, "vChaleco");

		jAutos[i][vID] = CreateVehicle(jAutos[i][vModelo], jAutos[i][vPosX], jAutos[i][vPosY], jAutos[i][vPosZ], jAutos[i][vPosA], jAutos[i][vColor1], jAutos[i][vColor2], jAutos[i][vRespawn], 0);
	    IDCars[i] = true;
	    if(vehTrunk[i][1] != 0) vehTrunkCounter[i]++, SlotsV[i]++;
	    if(vehTrunk[i][2] != 0) vehTrunkCounter[i]++, SlotsV[i]++;
	    if(vehTrunk[i][3] != 0) vehTrunkCounter[i]++, SlotsV[i]++;
	    SetVehicleParamsEx(i, 0, 0, 0, 0, 0, 0, 0);
   		SetVehicleHealth(i, 999.0);
        index++;
    }
    printf("Autos cargados: %i", index);
    return 1;
}
The result is this:

Reply
#2

That is normal as the cars only get added after the server has finished its setup. Have you actually checked in-game before posting here?
Reply
#3

Ready...
Reply
#4

Yeah it's because it counts car models at end of Gamemodeinit (or so I believe) and your callback takes some time to respond to query and create them, go check ingame first.
Mine says 0 too, but I always have those cars I created in-game.
Reply
#5

The mysql_log could be helpful.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)