07.10.2016, 14:40
(
Последний раз редактировалось GoldenLion; 08.10.2016 в 11:54.
)
Hi, I'm trying to create an inventory system right now, it works well but the GiveItem function doesn't work. Like if I give myself an item then the name is blank, but everything else works (count, etc).
Enum:
GiveItem function:
ShowInventory function (works like it's supposed to)
This is what it looks like in-game: https://gyazo.com/54524c83e6ea7a5ebf2b792f71d399d6
As you can see the inventory system works itself, but GiveItem not. I gave myself a Cellphone by setting ItemName and ItemCount manually in a command. What's the problem?
Enum:
Код:
enum inventoryInfo { ItemName[32], ItemCount } new InventoryInfo[MAX_PLAYERS][25][inventoryInfo];
Код:
GiveItem(playerid, item[], amount) { printf("%s", item); // <---- I checked if the item is blank here, but it's not. :P for (new i; i < 25; i++) //this part should check if player already has the item and just add the amount to the item's count if (!strcmp(InventoryInfo[playerid][i][ItemName], item)) return InventoryInfo[playerid][i][ItemCount] += amount; for (new i; i < 25; i++) if (!InventoryInfo[playerid][i][ItemCount]) //if player doesn't have the item already then it should find a free slot and give him the item { format(InventoryInfo[playerid][i][ItemName], 32, item); InventoryInfo[playerid][i][ItemCount] = amount; return 1; } return 0; }
Код:
ShowInventory(playerid) { new inventory[1250], item[50]; for (new i; i < 25; i++) { if (InventoryInfo[playerid][i][ItemCount]) { if (InventoryInfo[playerid][i][ItemCount] == 1) format(item, sizeof(item), "{FFFFFF}%d. %s\n", i + 1, InventoryInfo[playerid][i][ItemName]); else format(item, sizeof(item), "{FFFFFF}%d. %s (%d)\n", i + 1, InventoryInfo[playerid][i][ItemName], InventoryInfo[playerid][i][ItemCount]); } else format(item, sizeof(item), "{999999}%d. Empty Slot\n", i + 1); strcat(inventory, item); } ShowPlayerDialog(playerid, DIALOG_INVENTORY, DIALOG_STYLE_LIST, "Inventory", inventory, "Select", "Cancel"); return 1; }
As you can see the inventory system works itself, but GiveItem not. I gave myself a Cellphone by setting ItemName and ItemCount manually in a command. What's the problem?