BlueG's mysql question (delete please)
#1

The problem is that it isn't loading vehicles... none is created.

pawn Код:
mysql_tquery(mysql, "SELECT * FROM vehicles", "", "");
    for(new r=0; r < cache_num_rows(); ++r)
    {
        new ORM:vid = VehicleInfo[r][ORM_ID] = orm_create("vehicles");
        orm_addvar_int(vid, VehicleInfo[r][ID], "id");
        orm_setkey(vid, "id");
        orm_addvar_int(vid, VehicleInfo[r][vCost], "cost");
        orm_addvar_string(vid, VehicleInfo[r][vOwner], 21, "owner");
        orm_addvar_int(vid, VehicleInfo[r][vModel], "model");
        orm_addvar_int(vid, VehicleInfo[r][vColor1], "color1");
        orm_addvar_int(vid, VehicleInfo[r][vColor2], "color2");
        orm_addvar_float(vid, VehicleInfo[r][vPosX], "posx");
        orm_addvar_float(vid, VehicleInfo[r][vPosY], "posy");
        orm_addvar_float(vid, VehicleInfo[r][vPosZ], "posz");
        orm_addvar_float(vid, VehicleInfo[r][vAngle], "angle");
        orm_apply_cache(vid, r);
        VehicleInfo[r][VID] = AddStaticVehicleEx(VehicleInfo[r][vModel], VehicleInfo[r][vPosX], VehicleInfo[r][vPosY], VehicleInfo[r][vPosZ], VehicleInfo[r][vAngle], VehicleInfo[r][vColor1], VehicleInfo[r][vColor2], 300);
        SetVehicleToRespawn(r);
    }
Reply
#2

Its mysql r7 because its using cache.
Reply
#3

Well the problem is different now
Reply
#4

You cannot execute a query and directly call functions to retrieve data. You need to add a callback to mysql_tquery function and in that callback, you can retrieve the data.

Check the last example with loading vehicles: https://sampforum.blast.hk/showthread.php?tid=461766
Reply
#5

Changed

pawn Код:
OnGameModeInit:

mysql_tquery(mysql, "SELECT * FROM vehicles", "LoadVehicles", "");
pawn Код:
forward LoadVehicles();
public LoadVehicles()
{
    for(new r=0; r < cache_num_rows(); ++r)
    {
        new ORM:vid = VehicleInfo[r][ORM_ID] = orm_create("vehicles");
        orm_addvar_int(vid, VehicleInfo[r][ID], "id");
        orm_setkey(vid, "id");
        orm_addvar_int(vid, VehicleInfo[r][vCost], "cost");
        orm_addvar_string(vid, VehicleInfo[r][vOwner], 21, "owner");
        orm_addvar_int(vid, VehicleInfo[r][vModel], "model");
        orm_addvar_int(vid, VehicleInfo[r][vColor1], "color1");
        orm_addvar_int(vid, VehicleInfo[r][vColor2], "color2");
        orm_addvar_float(vid, VehicleInfo[r][vPosX], "posx");
        orm_addvar_float(vid, VehicleInfo[r][vPosY], "posy");
        orm_addvar_float(vid, VehicleInfo[r][vPosZ], "posz");
        orm_addvar_float(vid, VehicleInfo[r][vAngle], "angle");
        orm_apply_cache(vid, r);
        AddStaticVehicleEx(VehicleInfo[r][vModel], VehicleInfo[r][vPosX], VehicleInfo[r][vPosY], VehicleInfo[r][vPosZ], VehicleInfo[r][vAngle], VehicleInfo[r][vColor1], VehicleInfo[r][vColor2], 300);
        SetVehicleToRespawn(r);
    }
   return 1;
}
But still doesn't load.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)