Page 1 of 1

*SOLVED* Trying to fill an array with the item IDs in my...

Posted: Tue Nov 16, 2010 11:34 pm
by Exempt
I figured it out.. Not exactly sure why I needed to add (short) to get the correct output but it fixed it. As far as the +10 needing to be +16 I forgot to make it hex with 0x10.

Code: Select all

for(int i=0; i < 40; i++)
    {
        inventory[i] = memReadShort(invAdd+(i * 0x10));
        printf("Inventory Slot: %u, Item ID: %u, Inventory Address: %X\n", i, (short)inventory[i], invAdd+(i * 0x10));
    }
Ok, I'm trying to fill the "inventory" array up with all the ID's of items in my inventory. The variable invAdd is the address of the first element in the inventory array.

The odd thing is the array in memorys goes like this..
059E3FF4
059E4004
059E4014
059E4024
...
Always +10 to the last address. When I make the for loop like this.. The address are way off, When i add +16 like the bottom one the address shw up correctly but I don't get the right Item IDs.

Code: Select all

for(int i=0; i < 40; i++)
    {
        inventory[i] = memReadShort(invAdd+(i * 10));
        printf("Inventory Slot: %u, Item ID: %u, Inventory Address: %X\n", i, inventory[i],invAdd+(i * 10));
    }

Code: Select all

int invAdd = 0x59E3FF4;  //Memory address of the first element in the array.
int inventory[50]; //The array to hold the item IDs.

for(int i=0; i < 40; i++)
    {
        inventory[i] = memReadShort(invAdd+(i * 16));
        printf("Inventory Slot: %u, Item ID: %u, Inventory Address: %X\n", i, inventory[i],invAdd+(i * 16));
    }