Quote:
Originally Posted by several
<>
|
Sure, but the enum is just an enumerator, you can't pass it directly as a parameter like that, you need an array with the first dimension set as that enum so you have where to store the new values:
PHP код:
enum gePosInfo
{
Float:X,
Float:Y,
Float:Z,
INT,
VW
}
stock GetPlayerPosInfo( playerid, posInfo[ gePosInfo ] ) // you don't need & because arrays are automatically passed by reference
{
posInfo[ INT ] = GetPlayerVirtualWorld( playerid );
posInfo[ VW ] = GetPlayerInterior( playerid );
GetPlayerPos( playerid, posInfo[ X ], posInfo[ Y ], posInfo[ Z ] );
}
public OnPlayerUpdate( playerid )
{
new lPosInfo[ gePosInfo ] = { -1.0, -1.0, -1.0, -1, -1 };
printf( "Before: %f %f %f %d %d", lPosInfo[ X ], lPosInfo[ Y ], lPosInfo[ Z ], lPosInfo[ INT ], lPosInfo[ VW ] ); // prints -1.0, -1.0, -1.0, -1, -1
GetPlayerPosInfo( playerid, lPosInfo );
printf( "After: %f %f %f %d %d", lPosInfo[ X ], lPosInfo[ Y ], lPosInfo[ Z ], lPosInfo[ INT ], lPosInfo[ VW ] ); // prints correct values
return 1;
}
Also, about your 3D array problem: it is way better to use enums in that case:
PHP код:
enum someEnum
{
someString[ 8 ], // max string size is 8
someVar
};
new someArray[ 3 ][ someEnum ] =
{
{ "One", 1 },
{ "Two", 2 },
{ "Four", 3 }
};
// get elements:
for( new i = 0; i < sizeof( someArray ); i ++ )
{
printf( "someArray[ %d ] = { '%s', %d }", i, someArray[ i ][ someString ], someArray[ i ][ someVar ] );
}
With this method only what you need will be an actual sub-array: the string in this case (in Pawn, a string is an array of characters [represented by
ASCII values]), without setting the integer as an array too, which made no sense and is bad. Using enum in that case also offers more protection at compile time and you can easily access them by using the name of the element.