Mysql, no create vehicles...
#1

This code no create vehicles...

Quote:

public CargarAutos()
{
new qwerty[128];
new i = 1, iRows, iFields, NumbersCars;
cache_get_data(iRows, iFields, Conecction);
while(i < iRows)
{
cache_get_field_content(i, "vModelo", qwerty, Conecction); jAutos[i][vModelo] = strval(qwerty);
cache_get_field_content(i, "vPosX", qwerty, Conecction); jAutos[i][vPosX] = floatstr(qwerty);
cache_get_field_content(i, "vPosX", qwerty, Conecction);jAutos[i][vPosY] = floatstr(qwerty);
cache_get_field_content(i, "vPosZ", qwerty, Conecction); jAutos[i][vPosZ] = floatstr(qwerty);
cache_get_field_content(i, "vPosA", qwerty, Conecction); jAutos[i][vPosA] = floatstr(qwerty);
cache_get_field_content(i, "vColor1", qwerty, Conecction); jAutos[i][vColor1] = strval(qwerty);
cache_get_field_content(i, "vColor2", qwerty, Conecction); jAutos[i][vColor2] = strval(qwerty);
cache_get_field_content(i, "vRespawn", qwerty, Conecction); jAutos[i][vRespawn] = strval(qwerty);
cache_get_field_content(i, "vGasolina", qwerty, Conecction); jAutos[i][vGasolina] = strval(qwerty);
cache_get_field_content(i, "vMapa", qwerty, Conecction); jAutos[i][vMapa] = strval(qwerty);
cache_get_field_content(i, "vRadio", qwerty, Conecction); jAutos[i][vRadio] = strval(qwerty);
cache_get_field_content(i, "vBombas", qwerty, Conecction); jAutos[i][vBombas] = strval(qwerty);
cache_get_field_content(i, "vMedicinas", qwerty, Conecction); jAutos[i][vMedicinas] = strval(qwerty);
cache_get_field_content(i, "vBotiquines", qwerty, Conecction); jAutos[i][vBotiquines] = strval(qwerty);
cache_get_field_content(i, "vVendas", qwerty, Conecction); jAutos[i][vVendas] = strval(qwerty);
cache_get_field_content(i, "vBengalas", qwerty, Conecction); jAutos[i][vBengalas] = strval(qwerty);
cache_get_field_content(i, "vGanzuas", qwerty, Conecction); jAutos[i][vGanzuas] = strval(qwerty);
cache_get_field_content(i, "vDrogas", qwerty, Conecction); jAutos[i][vDrogas] = strval(qwerty);
cache_get_field_content(i, "vPalos", qwerty, Conecction); jAutos[i][vPalos] = strval(qwerty);
cache_get_field_content(i, "vFosforos", qwerty, Conecction); jAutos[i][vFosforos] = strval(qwerty);
cache_get_field_content(i, "vBaterias", qwerty, Conecction); jAutos[i][vBaterias] = strval(qwerty);
cache_get_field_content(i, "vAgua", qwerty, Conecction); jAutos[i][vAgua] = strval(qwerty);
cache_get_field_content(i, "vCarneFresca", qwerty, Conecction); jAutos[i][vCarneFresca] = strval(qwerty);
cache_get_field_content(i, "vLata", qwerty, Conecction); jAutos[i][vLata] = strval(qwerty);
cache_get_field_content(i, "vLataGasolina", qwerty, Conecction); jAutos[i][vLataGasolina] = strval(qwerty);
cache_get_field_content(i, "vChaleco", qwerty, Conecction); vehTrunkArmour[i] = floatstr(qwerty);
cache_get_field_content(i, "vArma1", qwerty, Conecction); vehTrunk[i][1] = strval(qwerty);
cache_get_field_content(i, "vArma2", qwerty, Conecction); vehTrunk[i][2] = strval(qwerty);
cache_get_field_content(i, "vArma3", qwerty, Conecction); vehTrunk[i][3] = strval(qwerty);
cache_get_field_content(i, "vBalas1", qwerty, Conecction); vehTrunkAmmo[i][1] = strval(qwerty);
cache_get_field_content(i, "vBalas2", qwerty, Conecction); vehTrunkAmmo[i][2] = strval(qwerty);
cache_get_field_content(i, "vBalas3", qwerty, Conecction); vehTrunkAmmo[i][3] = strval(qwerty);

i = GetFreeVehicleSlot();
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;
jAutos[i][vAviso] = 0;
jAutos[i][vAviso2] = 0;
jAutos[i][vAviso3] = 0;
jAutos[i][vAviso4] = 0;
jAutos[i][vAviso5] = 0;
new lights,alarm,doors,bonnet,boot,objective;
SetVehicleParamsEx(i,0,lights,alarm,doors,bonnet,b oot,objective);

i++;

for(new slot = 1; slot != 4; slot++)
{
vehTrunkCounter[i]=0;
}

NumbersCars = i;
}
printf("Autos cargados: %d", NumbersCars);
return 1;
}

stock CargarTodoAuto()
{
print("Cargando autos...");
mysql_function_query(Conecction, "SELECT * FROM `autos`", false, "CargarAutos", "");
return 1;
}

Help...
Reply
#2

Never re-use variables to do 2 different things in a loop.
You used "i" first to loop through your rows, then after loading all the data from the first vehicle, you re-use "i" for the vehicle-id.
It will mess up your loop and you'll end up loading only one vehicle.

Also, the first row is row 0, not 1.
Reply
#3

Use this code:
PHP код:
public CargarAutos()
{
    new 
iRowsiFields;
    
cache_get_data(iRowsiFieldsConecction);
    if(
iRows)
    {
        for(new 
0iRowsi++)
        {
            
jAutos[i][vModelo] = cache_get_field_content_int(i"vModelo");
            
jAutos[i][vPosX] = cache_get_field_content_float(i"vPosX");
            
jAutos[i][vPosY] = cache_get_field_content_float(i"vPosX");
            
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][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");
            
jAutos[i][vChaleco] = cache_get_field_content_float(i"vChaleco");
            
jAutos[i][vArma1] = cache_get_field_content_int(i"vArma1");
            
jAutos[i][vArma2] = cache_get_field_content_int(i"vArma2");
            
jAutos[i][vArma3] = cache_get_field_content_int(i"vArma3");
            
jAutos[i][vBalas1] = cache_get_field_content_int(i"vBalas1");
            
jAutos[i][vBalas2] = cache_get_field_content_int(i"vBalas2");
            
jAutos[i][vBalas3] = cache_get_field_content_int(i"vBalas3");
            
GetFreeVehicleSlot();
            
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;
            
jAutos[i][vAviso] =  jAutos[i][vAviso2] =  jAutos[i][vAviso3] =  jAutos[i][vAviso4] =  jAutos[i][vAviso5] = 0;
            new 
engine,lights,alarm,doors,bonnet,boot,objective;
            
GetVehicleParamsEx(ienginelightsalarmdoorsbonnetbootobjective)
            
SetVehicleParamsEx(i,0,lights,alarm,doors,bonnet,boot,objective);
            for(new 
slot 1slot != 4slot++) 
                
vehTrunkCounter[i]=0;
            
NumbersCars i;
        }
    }
    
printf("Autos cargados: %d"NumbersCars);
    return 
1;
}
stock CargarTodoAuto()
{
    print(
"Cargando autos...");
    
mysql_tquery(Conecction"SELECT * FROM `autos`""CargarAutos");
    return 
1;

Reply
#4

Why don't you just create the vehicle directly in the loop with the rest (engine to off) and not calling GetFreeVehicleSlot at all? Everything will be stored and then a loop to find if vehicle IDs do match would be fine.

@J4Rr3x: It will create only one vehicle as it's outside of the loop and "vehicleid" is undefined symbol in GetVehicleParamsEx function.
Reply
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Why don't you just create the vehicle directly in the loop with the rest (engine to off) and not calling GetFreeVehicleSlot at all? Everything will be stored and then a loop to find if vehicle IDs do match would be fine.

@J4Rr3x: It will create only one vehicle as it's outside of the loop and "vehicleid" is undefined symbol in GetVehicleParamsEx function.
Right, I've fixed my code.
Reply
#6

@J4Rr3x: Your code had some problems as Konstantinos says, but not yet resolved and shows good results ...

No create vehicles! HELPPPP
Reply
#7

But that shit console ?, says that the file loaded, entered the game and the cars appear, but all appear in the center of the map, what crazy not ?, someone might take me a hand with this ?, forgiveness for the double post.
Reply
#8

Try this:

PHP код:
public CargarAutos()
{
    new 
iRowsiFields;
    
cache_get_data(iRowsiFieldsConecction);
    if(
iRows)
    {
        for(new 
0iRowsi++)
        {
            
jAutos[i][vModelo] = cache_get_field_content_int(i"vModelo");
            
jAutos[i][vPosX] = cache_get_field_content_float(i"vPosX");
            
jAutos[i][vPosY] = cache_get_field_content_float(i"vPosX");
            
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][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");
            
jAutos[i][vChaleco] = cache_get_field_content_float(i"vChaleco");
            
jAutos[i][vArma1] = cache_get_field_content_int(i"vArma1");
            
jAutos[i][vArma2] = cache_get_field_content_int(i"vArma2");
            
jAutos[i][vArma3] = cache_get_field_content_int(i"vArma3");
            
jAutos[i][vBalas1] = cache_get_field_content_int(i"vBalas1");
            
jAutos[i][vBalas2] = cache_get_field_content_int(i"vBalas2");
            
jAutos[i][vBalas3] = cache_get_field_content_int(i"vBalas3");

            
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]);
            
IDCars[i] = true;
            
jAutos[i][vAviso] =  jAutos[i][vAviso2] =  jAutos[i][vAviso3] =  jAutos[i][vAviso4] =  jAutos[i][vAviso5] = 0;
            new 
engine,lights,alarm,doors,bonnet,boot,objective;
            
GetVehicleParamsEx(ienginelightsalarmdoorsbonnetbootobjective)
            
SetVehicleParamsEx(i,0,lights,alarm,doors,bonnet,boot,objective);
            for(new 
slot 1slot != 4slot++) 
                
vehTrunkCounter[i]=0;
            
NumbersCars++;
        }
    }
    
printf("Autos cargados: %d"NumbersCars);
    return 
1;
}

stock CargarTodoAuto()
{
    print(
"Cargando autos...");
    
mysql_tquery(Conecction"SELECT * FROM `autos`""CargarAutos");
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)