I need great help with mysql cache. -
Is there any way to call the cache of another function ?, for example .. I have this faction of truck drivers, I have created a dialogue in which the data of the mysql, all excellent up there, the problem is in when it selects something from the list I do not find how to get that value ..
Код:
Faction_ShowTruckersComputer(playerid)
{
new query[128];
mysql_format(sqlConnection, query, sizeof(query), "SELECT * FROM truckers_orders WHERE Company = %d ORDER BY id ASC", PlayerData[playerid][FactionID]);
mysql_tquery(sqlConnection, query, "SQL_ShowTruckersComputer", "i", playerid);
return true;
}
Server:SQL_ShowTruckersComputer(playerid)
{
new string[128], dialog[500];
if(cache_num_rows() == 0)return SendClientMessage(playerid, COLOR_WHITE, "No hay pedidos para esta compaсia.");
format(dialog, sizeof(dialog), ""COL_WHITE"Destino\t"COL_WHITE"Producto\t"COL_WHITE"Cantidad\t"COL_WHITE"Valor\n");
for(new order; order < cache_num_rows(); order++)
{
new To[60], Product[20], Quantity, Value;
cache_get_field_content(order, "To", To, sqlConnection, 60);
cache_get_field_content(order, "Product", Product, sqlConnection, 20);
Quantity = cache_get_field_content_int(order, "Quantity", sqlConnection);
Value = cache_get_field_content_int(order, "Value", sqlConnection);
format(string, sizeof(string), "%s\t%s\t%d\t%s"COL_MONEY"$\n", To, Product, Quantity, FormatNumber(Value));
strcat(dialog, string, sizeof(dialog));
}
Dialog_Show(playerid, TruckersOrders, DIALOG_STYLE_TABLIST_HEADERS, ""COL_RED"Lista de pedidos", dialog, "Aceptar", "Cancelar");
return true;
}
Dialog:TruckersOrders(playerid, response, listitem, inputtext[])
{
if(response)
{
new Value;
Value = cache_get_field_content_int(0, "Value", sqlConnection);
cmd_me(playerid, "Esta revisando la lista de pedidos en la computadora.");
new dialog[500];
format(dialog, sizeof dialog, "%d", FormatNumber(Value));
Dialog_Show(playerid, TruckersOrders, DIALOG_STYLE_MSGBOX, "Pedido pendiente.", dialog, "Aceptar", "Cancelar");
}
return true;
}
Re: I need great help with mysql cache. -
You can use the cache_save function to save the current cache in memory (so, you'd use it under SQL_ShowTruckersComputer) and then cache_set_active (use the ID returned from cache_save).
Re: I need great help with mysql cache. -
Thanks for the answer Abagail, I was able to perform the system as I wanted, I was already creating a code of at least 20 lines using global variables and others which I did not want, thanks again!