Thread: ItemInfoArray
View Single Post
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-20-2015 , 15:40   Re: ItemInfoArray
Reply With Quote #24

The signature is correct. What is not correct is the data type for ItemArrayInfo. You want to retrieve an address, so it should be "pointer" or "int".

Now you have a valid address, and you have figured out that the address doesn't start at the beginning of structure, you can dump the array.
Note: you need a similar file as "int" but for "string".

PHP Code:
    new baseAddress OrpheuMemoryGet("ItemInfoArray") - (is_linux_server() ? 24); // Not totally sure why, likely it's the address of .pszName. Don't know if the same for linux, looks like not.

    
const structureSize 44;
    const 
arrayElements 32;
    const 
memberSize    4;
    const 
membersCount  structureSize memberSize;
    const 
arraySize     arrayElements structureSize;
    
    
enum ItemInfo
    
{
        
IISlotIIPositionIIAmmo1IIMaxAmmo1IIAmmo2IIMaxAmmo2IINameIIMaxClipIIIdIIFlagsIIWeight
    
};
    
    new const 
ItemInfoIdentifiers[ItemInfo][] = 
    {
        
"slot""position""ammo1""maxammo1""ammo2""maxammo2""name""maxclip""id""flags""weight"
    
};

    new 
buffer[32];
    new 
value;
    
    for (new 
element 0element arrayElements; ++element)
    {
        if (
element == || element == || element == 31)
        {
            continue;
        }
        
        
server_print("Weapon ID %d"element);
        
        for (new 
ItemInfo:membermember membersCount; ++member)
        {
            
value OrpheuMemoryGetAtAddress(baseAddress + (element structureSize) + (any:member memberSize), "int");
            
            switch (
member)
            {
                case 
IIAmmo1IIAmmo2IIName:
                {
                    
value && OrpheuMemoryGetAtAddress(value"string"buffercharsmax(buffer));
                    
server_print("  %16s ^"%s^""ItemInfoIdentifiers[member], buffer);
                }
                default:
                {
                   
server_print("  %16s %d"ItemInfoIdentifiers[member], value);
                }
            }
        }
    } 
Feel free to adapt code now if you want to retrieve just a specific member.
__________________

Last edited by Arkshine; 08-20-2015 at 15:45.
Arkshine is offline