Here is an example of how I iterate through entries in PokeMod 2.0 for the items:
Code:
FileReadItems()
{
pokemod_funcstart_debug( "FileReadItems" );
SetupArray( g_iItemNames, NAME_LEN );
SetupArray( g_iItemTells, 1 );
SetupArray( g_iItemProps, 1 );
SetupTrie( g_iItemTrie );
new String:szData[128], Int:iTell, Int:iProp, ITEM_PROP:iPropNum;
new Int:iFileHandle = fopen( FileName( FILE_ITEMS ), "rt" );
while ( !feof( iFileHandle ) )
{
iTell = ftell( iFileHandle );
fgets( iFileHandle, szData, charsmax(szData) );
trim( szData );
if ( szData[ 0 ] == ';' || ( szData[ 0 ] == '/' && szData[ 1 ] == '/' ) )
continue;
if ( szData[ 0 ] == '#' )
{
TrieSetCell( g_iItemTrie, szData[1], ArraySize( g_iItemNames ) );
ArrayPushString( g_iItemNames, szData[1] );
ArrayPushCell( g_iItemTells, iTell );
ArrayPushCell( g_iItemProps, 0 );
}
else if ( equali( szData, "Prop ", 5 ) )
{
//Remove Prop
copy( szData, charsmax(szData), szData[ 5 ] );
iProp = 0;
new String:szLeft[ 64 ];
while ( ValidData( szData ) )
{
strbreak( szData, szLeft, charsmax(szLeft), szData, charsmax(szData) );
for ( iPropNum = ITEM_DEFAULT; iPropNum < ITEM_PROP; iPropNum++ )
{
if ( equali( szLeft, szItemProp[ iPropNum ] ) )
{
iProp |= ( 1 << _:iPropNum );
break;
}
}
if ( iPropNum == ITEM_PROP )
{
pokemod_debug( "FileReadItems Unknown Item Prop: '%s'", szLeft );
}
}
ArraySetCell( g_iItemProps, ArraySize( g_iItemProps ) - 1, iProp );
}
}
fclose( iFileHandle );
pokemod_funcend_debug( "FileReadItems %d", ArraySize( g_iItemNames ) );
}
Not sure if that helps you, but I thought you might be interested.