View Single Post
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 11-24-2012 , 17:04   Re: New File Vault - A newer file vault system!
Reply With Quote #28

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.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`