Как передать двумерный массив в аргумент native?
Сейчас делаю так:
Plugin1:
Inc:
Plugin2:
Мб есть лучше способ?
Сейчас делаю так:
Plugin1:
Код:
#define IsValidArray(%0) bool: ( %0 != Invalid_Array )
public plugin_natives( )
{
g_aSounds1 = ArrayCreate( 64 );
g_aSounds2 = ArrayCreate( 64 );
register_native( "_register_sounds", "Native__RegisterSounds" );
}
public bool: Native__RegisterSounds( )
{
new Array: aSounds = Array: get_param( 1 );
if ( !IsValidArray( aSounds ) )
return false;
new szBuffer[ 64 ], iSounds1 = get_param( 2 );/*, iSounds2 = get_param( 3 );*/
for ( new i = 0; i < ArraySize( aSounds ); i++ )
{
ArrayGetString( aSounds, i, szBuffer, charsmax( szBuffer ) );
engfunc( EngFunc_PrecacheSound, szBuffer );
ArrayPushString( ( i < iSounds1 ) ? g_aSounds1 : g_aSounds2, szBuffer );
server_print( "%i.Sound %s", i, szBuffer );
}
ArrayDestroy( aSounds );
return true;
}
Код:
native bool: _register_sounds( const Array: aSounds, iSounds1/*, iSounds2*/ );
stock bool: hoh_register_sounds( const Sounds1[ ][ ], const Sounds2[ ][ ], iSounds1 = sizeof Sounds1, iSounds2 = sizeof Sounds2 )
{
new Array: aSounds = ArrayCreate( 64 ), i;
for ( i = 0; i < iSounds1; i++ ) ArrayPushString( aSounds, Sounds1[ i ] );
iSounds1 = ArraySize( aSounds );
for ( i = 0; i < iSounds2; i++ ) ArrayPushString( aSounds, Sounds2[ i ] );
//iSounds2 = ArraySize( aSounds );
return _register_sounds( aSounds, iSounds1/*, iSounds2*/ );
}
Код:
new const HOH_SOUNDS1[ ][ ] = { "hoh1.wav", "hoh1.wav" };
new const HOH_SOUNDS2[ ][ ] = { "hoh3.wav", "hoh4.wav" };
public plugin_init( )
{
hoh_register_sounds( HOH_SOUNDS1, HOH_SOUNDS2 )
}
Последнее редактирование: