13.04.2017, 07:12
I have a items system but when restart the server i need to set on order
For example if:
On load, i need to change to:
I've tried this OrderItems(), but after add it i can't load...
It printing:
And if i remove OrderItems() load right, with no order ofc
For example if:
Код:
itemLIST 15 is itemID 11 itemLIST 16 is itemID 0 itemLIST 17 is itemID 0 itemLIST 18 is itemID 25
Код:
itemLIST 15 is itemID 11 itemLIST 16 is itemID 25 (from 18)
It printing:
Код:
[21:13:34] ================= [21:13:34] ordenar items [21:13:34] ================= [21:13:34] itemloop [0] itemID [15] [21:13:34] itemloop [0] itemID [16] [21:13:34] itemloop [0] itemID [17] [21:13:34] itemloop [0] itemID [18] [21:13:34] itemloop [0] itemID [19] [21:13:34] itemloop [0] itemID [20]
PHP код:
LoadItems() {
new listloop = ServerStoreItems + 1;
while(listloop < MAX_LISTS) {
new query[50]; // Nгo precisa ser enorme como vocк tinha colocado; Precisa apenas caber sua query dentro dela
mysql_format(ConnectMYSQL, query, sizeof(query), "SELECT * FROM items WHERE itemLIST = '%d'", listloop);
mysql_tquery(ConnectMYSQL, query, "Load_Items", "i", listloop);
listloop++;
}
OrderItems();
}
forward Load_Items(listloop); public Load_Items(listloop) {
new rows, fields;
cache_get_row_count(rows);
cache_get_field_count(fields);
if(rows) {
// ints
cache_get_value_int(0, "itemID", ItemInfo[listloop][itemID]);
}
}
forward OrderItems(); public OrderItems() {
printf("=================");
printf("ordenar items");
printf("=================");
new lastitem = ServerStoreItems+1;
for(new itemloop = ServerStoreItems+1; itemloop < MAX_LISTS; itemloop++) {
printf("itemloop [%i] itemID [%i]", ItemInfo[itemloop][itemID], itemloop);
if(ItemInfo[itemloop][itemID] > 0) {
lastitem++;
printf("lastitem [%i]", lastitem);
ItemInfo[lastitem][itemID] = ItemInfo[itemloop][itemID];
new squery[2500];
mysql_format(ConnectMYSQL, squery, sizeof(squery), "UPDATE `items` SET `itemID` = '%d' WHERE itemLIST = '%d'",
ItemInfo[lastitem][itemID],
lastitem);
mysql_pquery(ConnectMYSQL, squery);
}
}
}