Problem with MySQL V7 (BlueG's) -
LocMax - 02.07.2014
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);
}
Re: BlueG's mysql question -
MacT - 02.07.2014
Its mysql r7 because its using cache.
Re: BlueG's mysql question (delete please) -
LocMax - 02.07.2014
Well the problem is different now
Re: BlueG's mysql question (delete please) -
Konstantinos - 02.07.2014
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
Re: BlueG's mysql question (delete please) -
LocMax - 02.07.2014
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.