21.07.2013, 09:57
If you have foreach include, read the section about custom iterators. Otherwise:
1. Remove item
2. Move all items to -1 slot
3. Decrease number of clothes
Remember to update HasClothes on addition/removal of clothes.
There is also fancy way using pointer swapping (introduced by Slice https://sampforum.blast.hk/showthread.php?tid=343172 ), but I think it won't be necessary.
pawn Код:
stock RemoveClothes(playerid,slotid)
{
ClothesItems[playerid][slotid] = 0;
for(new i = slotid + 1; i != HasClothes[playerid]; ++i) {
ClothesItems[playerid][i - 1] = ClothesItems[playerid][i];
}
HasClothes[playerid]--;
return 1;
}
2. Move all items to -1 slot
3. Decrease number of clothes
Remember to update HasClothes on addition/removal of clothes.
There is also fancy way using pointer swapping (introduced by Slice https://sampforum.blast.hk/showthread.php?tid=343172 ), but I think it won't be necessary.