04.10.2012, 05:00
Quote:
Thanks for the good tutorial!
I succeeded on converting my cmds from normal threaded queries to cache, but im stuck on this were server is supposed to load all vehicles. How to make this with cache? Note: 'mysql_cquery' is a macro, so nvm that, its enabled cache. pawn Код:
|
pawn Код:
enum vInfo
{
vid,
Float:vPos[4],
vmodel,
vcolor1,
vcolor2
}
new gVehicles[MAX_VEHICLES][vInfo];
stock LoadVehicles()
{
return mysql_function_query(1, "SELECT * FROM `vehicles", true, "OnVehicleLoad", "");
}
forward OnVehicleLoad();
public OnVehicleLoad()
{
new rows, fields, content[40];
cache_get_data(rows, fields);
new i;
for(i=0; i<rows; i++) {
cache_get_field_content(i, "vX", content), gVehicles[i][vPos][0] = floatstr(content),
cache_get_field_content(i, "vY", content), gVehicles[i][vPos][1] = floatstr(content),
cache_get_field_content(i, "vZ", content), gVehicles[i][vPos][2] = floatstr(content),
cache_get_field_content(i, "vA", content), gVehicles[i][vPos][3] = floatstr(content),
cache_get_field_content(i, "vModel", content), gVehicles[i][vmodel] = strval(content),
cache_get_field_content(i, "vcolor1", content), gVehicles[i][vcolor1] = strval(content),
cache_get_field_content(i, "vcolor2", content), gVehicles[i][vcolor2] = strval(content);
gVehicles[i][vid] = CreateVehicle(...); // fill with with variables fetched above
}
printf("%d vehicles loaded from database.", i);
return 1;
}