ERROR 029: Help, please.
#1

I'm developing an inventory system, why is this not working? It looks like it should, but I'm getting ERROR 029: INVALID EXPRESSION, ASSUMED ZERO.

It's a simple, text based inventory. Help please!

//Inventory.

enum ItemData
{
Name[20],
AmmoType[20],
WeaponID,
Condition,
Quantity,
Ammo,
Rarity,
InventoryID
}

new Items[18][ItemData] =
{
{"M1911", ".45 Cal", 22, 0, 1, 0, 1},
{"M1911 SD", ".45 Cal", 23, 0, 1, 0, 2},
{"Desert Eagle", ".50 Cal", 24, 0, 1, 0, 3},
{"Remington 870", "12 Gauge", 25, 0, 1, 0, 4},
{"Double Barrel", "12 Gauge", 26, 0, 1, 0, 5},
{"SPAS-12", "20 Gauge", 26, 0, 1, 0, 6},
{"Mac 10", "9mm", 27, 0, 1, 0, 7},
{"MP5", "9mm", 28, 0, 1, 0, 8},
{"AKM", "7.62mm", 31, 0, 1, 0, 9},
{"M4A1", "5.56mm", 31, 0, 1, 0, 10},
{"Tec-9", "9mm", 32, 0, 1, 0, 11},
{"Winchester 94", ".32 cal", 33, 0, 1, 0, 12},
{"Remington 700", ".308", 34, 0, 1, 0, 13},
{"RPG-7", "40mm Warhead", 35, 0, 1, 0, 14},
{"M2 Flamethrower", "Napalm", 37, 0, 1, 0, 15},
{"M134 Minigun", "7.62mm", 38, 0, 1, 0, 16},
{"C4", "%0", 39, 0, 1, 0, 17},
{"C4 Detonator", "%0", 29, 0, 1, 0, 18}
};

new slot1, slot2, slot3, slot4, slot5;

new playerInventory[5][ItemData] =
{
slot1 = Items[][Name],
slot2,
slot3,
slot4,
slot5
};

The error is on the line "slot1 = Items[][Name],"
Reply
#2

change this:
pawn Код:
new playerInventory[5][ItemData] =
{
slot1 = Items[][Name],
slot2,
slot3,
slot4,
slot5
};
to this:
pawn Код:
new playerInventory[5][ItemData] =
{
slot1 ,
slot2,
slot3,
slot4,
slot5
};
Reply
#3

But then I can't store items into the slots...
Reply
#4

no you can , you already defined the enums so slot1 will be playerInventory[1][ItemData] and
slot2 will be playerInventory[2][ItemData] and so on
Reply
#5

It's like an array within an array and giving me the same error, still.
Reply
#6

instead of :
pawn Код:
new playerInventory[5][ItemData] =
{
slot1 ,
slot2,
slot3,
slot4,
slot5
};
do:
pawn Код:
enum ItemData
{
slot1 ,
slot2,
slot3,
slot4,
slot5
};
then
pawn Код:
new playerInventory[MAX_PLAYERS][ItemData];
Reply
#7

But enums are for integer storage only, and the names are stored in strings. As much as I appreciate your help, I've thought most of this through already, I'm so sorry
Reply
#8

no it's not for integers only.
you can simply replace this:
pawn Код:
enum ItemData
{
slot1 ,
slot2,
slot3,
slot4,
slot5
};
to:
pawn Код:
enum ItemData
{
slot1[39] ,
slot2[39],
slot3[39],
slot4[39],
slot5[39]
};
now it's string instead of integer.
Reply
#9

Enums do save strings aslong as you define the string size.

Also, your array wouldn't work since you didn't define a playerid. You also won't really need to store the item name in your enum as you should be able to retrieve it from the array.

This is taken from my own inventory system, hopefully you can get the idea of what I'm trying to say:

The item array:

pawn Код:
new InventoryItems[MAX_INV_ITEMS][][] = {
//  ID      Name of Item        Obj ID

    {0,     "Untied Rope",      964},
    {1,     "Wood Blocks",      1463},
    {2,     "Hunting Knife",    335}
};
Storing them using these defines and variables:

pawn Код:
#define MAX_INV_SLOTS   5

// Store item ID inside of this
new pInv_Item[MAX_PLAYERS][MAX_INV_SLOTS];
new pInv_Value[MAX_PLAYERS][MAX_INV_SLOTS];
Retrieving the name from the array, this would work (please note: pInv_Item is actually the player's inventory, I will emphasize inside the [pawn] code:

pawn Код:
for(new i = 0; i < MAX_INV_SLOTS; i ++)
{
         InventoryItems[ pInv_Item[playerid][i] ][1][0]
}

// To explain the following;  "i" equals the player's inventory slot: which saves the item ID -- empty slots are "0", that's how you find them.

pInv_Item[playerid][i]
EDIT: Thanks Eth (:
Reply
#10

I appreciate the help, Mionee, but you've still unfortunately got me slightly lost. I get what you're trying to say, but I really don't understand the idea of using MAX_INV_SLOTS or playerid.
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)