22.10.2017, 12:54
Hi. I started working on a new gamemode and now I came to the part where I need to add random loot spawns. What I made is an array with all positions and an array of items which contains items' names, models and whether they can be spawned as loot or not. Here's the function:
It seems to be absolutely fine for me, but I'm getting this error:
on the marked line. The problem seems to be at where I'm getting the random item's name and model here:
because when I replace them with something else like "test", 123 it compiles fine.
This is what the array looks like:
Does anybody spot a mistake here that I don't?
Код:
RespawnItems()
{
new index;
for (new i; i < MAX_ITEMS; i++) if (ItemInfo[i][iModel] && gettime() - ItemInfo[i][iCreateTime] > 900)
DestroyItem(i);
for (new i; i < sizeof(g_LootSpawns); i++)
{
do index = random(sizeof(g_Items));
while(!g_Items[index][iLootSpawn]);
CreateItem(g_Items[index][iName], g_Items[index][iModel], g_LootSpawns[i][0], g_LootSpawns[i][1], g_LootSpawns[i][2], 0, 0);
}
g_LootRespawnTime = 3600;
printf("%d items created.", sizeof(g_LootSpawns));
}
Код:
array sizes do not match, or destination array is too small
Код:
g_Items[index][iName], g_Items[index][iModel]
This is what the array looks like:
Код:
enum e_Items
{
iName[20],
iModel,
iLootSpawn
}
new g_Items[][e_Items] =
{
{"Sandwich", 2663, true},
{"Kebar Roll", 2769, true},
{"Burger", 2768, true}
}



. Could you share only the header of your CreateItem function? Also have you tried to printf all of the values to see if there's any anomaly?