Can't load the good numbers.
#1

Alright, i want to load the components from database but i don't know why it gives me wrong numbers.

For each mod component i told him to show the id from the car and component id but it says: vehid: number(this works ok) comp: here it send 48, 46 only.

Here is the code.

pawn Код:
mysql_fetch_field_row(vmod[0], "mod1"); mysql_fetch_field_row(vmod[1], "mod2"); mysql_fetch_field_row(vmod[2], "mod3"); mysql_fetch_field_row(vmod[3], "mod4");
            mysql_fetch_field_row(vmod[4], "mod5"); mysql_fetch_field_row(vmod[5], "mod6"); mysql_fetch_field_row(vmod[6], "mod7"); mysql_fetch_field_row(vmod[7], "mod8");
            mysql_fetch_field_row(vmod[8], "mod9"); mysql_fetch_field_row(vmod[9], "mod10"); mysql_fetch_field_row(vmod[10], "mod11"); mysql_fetch_field_row(vmod[11], "mod12");
           
            car = AddStaticVehicle(strval(modelid), floatstr(x), floatstr(y), floatstr(z), floatstr(a), strval(color1), strval(color2));
           
            SetVehicleNumberPlate(car, plate);
            total_private_vehicles[car]++;

            vmods[car][0] = vmod[0];            vmods[car][1] = vmod[1];            vmods[car][2] = vmod[2];            vmods[car][3] = vmod[3];            vmods[car][4] = vmod[4];
            vmods[car][5] = vmod[5];            vmods[car][6] = vmod[6];            vmods[car][7] = vmod[7];            vmods[car][8] = vmod[8];            vmods[car][9] = vmod[9];
            vmods[car][10] = vmod[10];          vmods[car][11] = vmod[11];


            for(new i = 0; i < MAX_VEH_MODS; ++i)
            {
                if(vmods[car][i] > 0)
                {
                    AddVehicleComponent(car, vmods[car][i]);

                    new string[126];
                   
                    format(string, sizeof(string), "VehID: %i , comp: %i", car, vmods[car][i]);
                    SendClientMessage(playerid, -1, string);
                }
            }
Reply
#2

bump
Reply
#3

maybe you should use strval?
Reply
#4

I tried also with strval, still nothing, its gave me 1000000 etc, numbers like that.
Reply
#5

For all of your

pawn Код:
vmods[car][0] = vmod[0];
change them to

pawn Код:
vmods[car][0] = strval(vmod[0]);
Private message me the whole function and I'll help you make it more efficient, because mysql_fetch_field_row repeatedly is inefficient.
Reply
#6

did -.-, still nothing
Reply
#7

Use strval...
Reply
#8

I DID!

LOOOK

pawn Код:
mysql_fetch_field_row(vmod[0], "mod1"); mysql_fetch_field_row(vmod[1], "mod2"); mysql_fetch_field_row(vmod[2], "mod3"); mysql_fetch_field_row(vmod[3], "mod4");
            mysql_fetch_field_row(vmod[4], "mod5"); mysql_fetch_field_row(vmod[5], "mod6"); mysql_fetch_field_row(vmod[6], "mod7"); mysql_fetch_field_row(vmod[7], "mod8");
            mysql_fetch_field_row(vmod[8], "mod9"); mysql_fetch_field_row(vmod[9], "mod10"); mysql_fetch_field_row(vmod[10], "mod11"); mysql_fetch_field_row(vmod[11], "mod12");

            vmods[car][0] = strval(vmod[0]);            vmods[car][1] = strval(vmod[1]);            vmods[car][2] = strval(vmod[2]);            vmods[car][3] = strval(vmod[3]);            vmods[car][4] = strval(vmod[4]);
            vmods[car][5] = strval(vmod[5]);            vmods[car][6] = strval(vmod[6]);            vmods[car][7] = strval(vmod[7]);            vmods[car][8] = strval(vmod[8]);            vmods[car][9] = strval(vmod[9]);
            vmods[car][10] = strval(vmod[10]);          vmods[car][11] = strval(vmod[11]);


            car = AddStaticVehicle(strval(modelid), floatstr(x), floatstr(y), floatstr(z), floatstr(a), strval(color1), strval(color2));

            SetVehicleNumberPlate(car, plate);

            for(new i = 0; i < 12; ++i)
            {
                AddVehicleComponent(car, vmods[car][i]);
                new string[126];
                format(string, sizeof(string), "VehID: %i , compo: %i", car, vmods[car][i]);
                SendClientMessage(playerid, -1, string);

            }
I get this messages: 12x "VehID: 64 , compo: 0"


Also i checked the debug, numbers are loading correctly.
Reply
#9

Alright, this is the hole code.

pawn Код:
new vmods[MAX_VEHICLES][MAX_VEH_MODS]

stock Load_Pvehs(playerid){
 
    new modelid[5], x[20], y[20], z[20], a[20], color1[5], color2[5], car, plate[20], query[200], vmod[12];
    format(query, sizeof(query), "SELECT * FROM `private_veh` WHERE `name` LIKE '%s' LIMIT 1", pname);
    GetPlayerName(playerid, pname, sizeof(pname));
    mysql_query(query);
    mysql_store_result();
    if(mysql_num_rows() != 0){
        while(mysql_fetch_row(query)){
            mysql_fetch_field_row(modelid, "modelid");
            mysql_fetch_field_row(x, "spawn_x");
            mysql_fetch_field_row(y, "spawn_y");
            mysql_fetch_field_row(z, "spawn_z");
            mysql_fetch_field_row(a, "angle");
            mysql_fetch_field_row(color1, "color1");
            mysql_fetch_field_row(color2, "color2");
            mysql_fetch_field_row(plate, "plate");
            mysql_fetch_field_row(vmod[0], "mod1"); mysql_fetch_field_row(vmod[1], "mod2"); mysql_fetch_field_row(vmod[2], "mod3"); mysql_fetch_field_row(vmod[3], "mod4");
            mysql_fetch_field_row(vmod[4], "mod5"); mysql_fetch_field_row(vmod[5], "mod6"); mysql_fetch_field_row(vmod[6], "mod7"); mysql_fetch_field_row(vmod[7], "mod8");
            mysql_fetch_field_row(vmod[8], "mod9"); mysql_fetch_field_row(vmod[9], "mod10"); mysql_fetch_field_row(vmod[10], "mod11"); mysql_fetch_field_row(vmod[11], "mod12");

            vmods[car][0] = strval(vmod[0]);            vmods[car][1] = strval(vmod[1]);            vmods[car][2] = strval(vmod[2]);            vmods[car][3] = strval(vmod[3]);            vmods[car][4] = strval(vmod[4]);
            vmods[car][5] = strval(vmod[5]);            vmods[car][6] = strval(vmod[6]);            vmods[car][7] = strval(vmod[7]);            vmods[car][8] = strval(vmod[8]);            vmods[car][9] = strval(vmod[9]);
            vmods[car][10] = strval(vmod[10]);          vmods[car][11] = strval(vmod[11]);


            car = AddStaticVehicle(strval(modelid), floatstr(x), floatstr(y), floatstr(z), floatstr(a), strval(color1), strval(color2));

            SetVehicleNumberPlate(car, plate);

            for(new i = 0; i < 12; ++i){
                AddVehicleComponent(car, vmods[car][i]);
                new string[126];
                format(string, sizeof(string), "VehID: %i , compo: %i", car, vmods[car][i]);
                SendClientMessage(playerid, -1, string);

            }
            total_private_vehicles[car]++;
            format(query, sizeof(query), "UPDATE `private_veh` SET `vid` = %i WHERE `name` LIKE '%s' LIMIT 1", car, pname);
            mysql_query(query);
        }
    }
    mysql_free_result();
    return 1;
}
Reply
#10

Bump
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)