09.07.2016, 08:11
Hello! I make a inventory system using a multi-iterator system for items per-players. But my problem is that server is crashing, when i use a Iter_SafeRemove in foreach loop and after this again loop in other function. This is:
Just somebody know, that's why my server is crashing when after deleting loop i use a ListPlayerItems? That is'nt bug in y_iterator?
Код:
foreach(new itemid : PlayerItem[playerid]) { if(PlayerItemCache[playerid][itemid][iUID]) { UnloadPlayerItem(playerid, itemid); Iter_SafeRemove(PlayerItem[playerid], itemid, next_player_item); itemid = next_player_item; } } public UnloadPlayerItem(playerid, itemid) { for(new sPlayerItem:e; e < sPlayerItem; ++e) PlayerItemCache[playerid][itemid][e] = 0; orm_destroy(PlayerItemCache[playerid][itemid][iOrm]); return 1; } public ListPlayerItems(playerid) { new list_items[2048], item_count = Iter_Count(PlayerItem[playerid]), item_weight, item_weight_sum; format(list_items, sizeof(list_items), "UID\tNazwa przedmiotu\tWaga\n \t» Funkcja zaznaczania\n \t» Przedmioty w pobliżu\n---\n"); foreach(new itemid : PlayerItem[playerid]) { if(PlayerItemCache[playerid][itemid][iUID]) { item_weight = GetPlayerItemWeight(playerid, itemid); if(PlayerItemCache[playerid][itemid][iUsed]) { format(list_items, sizeof(list_items), "%s\n{FFFFFF}%d\t{C0C0C0}%s\t%dg", list_items, PlayerItemCache[playerid][itemid][iUID], PlayerItemCache[playerid][itemid][iName], item_weight); } else { format(list_items, sizeof(list_items), "%s\n{C0C0C0}%d\t{C0C0C0}%s\t%dg", list_items, PlayerItemCache[playerid][itemid][iUID], PlayerItemCache[playerid][itemid][iName], item_weight); } item_weight_sum += item_weight; } } if(item_count > 0) { new title[256]; format(title, sizeof(title), "Lista Twoich przedmiotуw [ilość: %d | suma wag: %dg]", item_count, item_weight_sum); ShowPlayerDialog(playerid, D_ITEM_USE, DIALOG_STYLE_TABLIST_HEADERS, title, list_items, "Użyj", "Opcje..."); } else { TD_ShowSmallInfo(playerid, 5, "Nie posiadasz ~r~zadnych ~w~przedmiotow w ekwipunku."); } return 1; }