Y_INI Question
#1

What am I doing wrong? The print won't show up, so I assume it's something to do with my ParseFile.

My house enum:

pawn Код:
enum hVars {
            EnterInteriorID, // The interior they are teleported to!
    Float:  EnterInteriorPosition [ 3 ], // Where they get teleported to when they enter the house!
            EnterVirtualWorldID,
           
    Float:  ExitExteriorPosition [ 4 ], // Where they get teleported to when they exit the house! (also where they enter)
            ExitInteriorID,
            ExitVirtualWorldID,
           
            IsLocked,
            HouseOwner [ MAX_PLAYER_NAME ]
};

new
            houStats [ MAX_HOUSES ] [ hVars ],
    bool:   houCreated [ MAX_HOUSES ] = false,
            houID [ MAX_HOUSES ] = -1;
OnGameModeInit:
pawn Код:
LoadHouses ( );
LoadHouses:
pawn Код:
stock LoadHouses ( )
{
    for( new h; h < MAX_HOUSES; h ++ )
    {
        if( fexist( FindHouseFile( h ) ) ) // The house exists in the directory!
        {
            INI_ParseFile( FindHouseFile( h ), "LoadHouse_%s", .bExtra = true, .extra = h );
        }
    }
    return true;
}
FindHouseFile & FindOpenHouseID
pawn Код:
stock FindHouseFile ( houseid )
{
    new
            houStr [ 128 ];
           
    format( houStr, sizeof houStr, DIRECTORY_HOUSES, houseid );
    return houStr;
}

stock FindOpenHouseID ( )
{
    new
            hID = -1;
           
    for( new h; h < MAX_HOUSES; h ++ )
    {
        if( !fexist( FindHouseFile( h ) ) )
        {
            return hID = h;
        }
    }
    return hID;
}
Loading everything:
pawn Код:
forward LoadHouse_data ( houseid, name[], value[] );
public LoadHouse_data ( houseid, name[], value[] )
{
    INI_Int(        "EnterInteriorID",          houStats [ houseid ] [ EnterInteriorID ] );
    INI_Int(        "EnterVirtualWorldID",      houStats [ houseid ] [ EnterVirtualWorldID ] );
    INI_Float(      "EnterInteriorPosition_X",  houStats [ houseid ] [ EnterInteriorPosition ] [ 0 ] );
    INI_Float(      "EnterInteriorPosition_Y",  houStats [ houseid ] [ EnterInteriorPosition ] [ 1 ] );
    INI_Float(      "EnterInteriorPosition_Z",  houStats [ houseid ] [ EnterInteriorPosition ] [ 2 ] );
   
    INI_Int(        "ExitInteriorID",           houStats [ houseid ] [ ExitInteriorID ] );
    INI_Int(        "ExitVirtualWorldID",       houStats [ houseid ] [ ExitVirtualWorldID ] );
    INI_Float(      "ExitExteriorPosition_X",   houStats [ houseid ] [ ExitExteriorPosition ] [ 0 ] );
    INI_Float(      "ExitExteriorPosition_Y",   houStats [ houseid ] [ ExitExteriorPosition ] [ 1 ] );
    INI_Float(      "ExitExteriorPosition_Z",   houStats [ houseid ] [ ExitExteriorPosition ] [ 2 ] );
   
    INI_Int(        "IsLocked",                 houStats [ houseid ] [ IsLocked ] );
    INI_String(     "HouseOwner",               houStats [ houseid ] [ HouseOwner ], MAX_PLAYER_NAME );
   
    houID [ houseid ] = houseid;
    houCreated [ houseid ] = true;
    printf("ID: %d, VW: %d", houID [ houseid ], houStats [ houseid ] [ EnterVirtualWorldID ] ); // This won't show up.
    return true;
}
Reply
#2

pawn Код:
enum hVars {
            EnterInteriorID, // The interior they are teleported to!
    Float:  EnterInteriorPosition [ 3 ], // Where they get teleported to when they enter the house!
            EnterVirtualWorldID,
           
    Float:  ExitExteriorPosition [ 4 ], // Where they get teleported to when they exit the house! (also where they enter)
            ExitInteriorID,
            ExitVirtualWorldID,
           
            IsLocked,
            HouseOwner [ MAX_PLAYER_NAME ]
};

new
            houStats [ MAX_HOUSES ] [ hVars ],
    bool:   houCreated [ MAX_HOUSES ] = false,
            houID [ MAX_HOUSES ] = -1;
OnGameModeInit:
pawn Код:
LoadHouses ( );
LoadHouses:
pawn Код:
stock LoadHouses ( )
{
    for( new h; h < MAX_HOUSES; h ++ )
    {
        if( fexist( FindHouseFile( h ) ) ) // The house exists in the directory!
        {
            INI_ParseFile( FindHouseFile( h ), "LoadHouseData", .bExtra = true, .extra = h );
        }
    }
    return true;
}
FindHouseFile & FindOpenHouseID
pawn Код:
stock FindHouseFile ( houseid )
{
    new
            houStr [ 128 ];
           
    format( houStr, sizeof houStr, DIRECTORY_HOUSES, houseid );
    return houStr;
}

stock FindOpenHouseID ( )
{
    new
            hID = -1;
           
    for( new h; h < MAX_HOUSES; h ++ )
    {
        if( !fexist( FindHouseFile( h ) ) )
        {
            return hID = h;
        }
    }
    return hID;
}
Loading everything:
pawn Код:
forward LoadHouseData ( houseid, name[], value[] );
public LoadHouseData ( houseid, name[], value[] )
{
    INI_Int(        "EnterInteriorID",          houStats [ houseid ] [ EnterInteriorID ] );
    INI_Int(        "EnterVirtualWorldID",      houStats [ houseid ] [ EnterVirtualWorldID ] );
    INI_Float(      "EnterInteriorPosition_X",  houStats [ houseid ] [ EnterInteriorPosition ] [ 0 ] );
    INI_Float(      "EnterInteriorPosition_Y",  houStats [ houseid ] [ EnterInteriorPosition ] [ 1 ] );
    INI_Float(      "EnterInteriorPosition_Z",  houStats [ houseid ] [ EnterInteriorPosition ] [ 2 ] );
   
    INI_Int(        "ExitInteriorID",           houStats [ houseid ] [ ExitInteriorID ] );
    INI_Int(        "ExitVirtualWorldID",       houStats [ houseid ] [ ExitVirtualWorldID ] );
    INI_Float(      "ExitExteriorPosition_X",   houStats [ houseid ] [ ExitExteriorPosition ] [ 0 ] );
    INI_Float(      "ExitExteriorPosition_Y",   houStats [ houseid ] [ ExitExteriorPosition ] [ 1 ] );
    INI_Float(      "ExitExteriorPosition_Z",   houStats [ houseid ] [ ExitExteriorPosition ] [ 2 ] );
   
    INI_Int(        "IsLocked",                 houStats [ houseid ] [ IsLocked ] );
    INI_String(     "HouseOwner",               houStats [ houseid ] [ HouseOwner ], MAX_PLAYER_NAME );
   
    houID [ houseid ] = houseid;
    houCreated [ houseid ] = true;
    printf("ID: %d, VW: %d", houID [ houseid ], houStats [ houseid ] [ EnterVirtualWorldID ] ); // This won't show up.
    return true;
}
Try that. I also need to see your INI File for the layout
Reply
#3

Was just testing something using the command /hcreate:

pawn Код:
CMD:hcreate(playerid,params[])
{
    new
        int, vw;
    if( sscanf(params, "ii", int, vw ) )
        return false;

    if( FindOpenHouseID ( ) == -1 )
        return SendClientMessage( playerid, Colour_Red, "» Sorry! "#Int_White"You have reached the maximum amount of houses." );

    new
         INI:   hFile = INI_Open( FindHouseFile( FindOpenHouseID ( ) ) );

    INI_SetTag( hFile,          "data" );

    INI_WriteInt( hFile,        "EnterVirtualWorldID",     vw );

    INI_Close( hFile );
    return true;
}
It writes everything correctly, the file name is "0.ini", of course, the number increases with the number of houses. With your code, there is still no print.
Reply
#4

try printing like that
pawn Код:
stock LoadHouses ( )
{
    for( new h; h < MAX_HOUSES; h ++ )
    {
        if( fexist( FindHouseFile( h ) ) ) // The house exists in the directory!
   
        {
            INI_ParseFile( FindHouseFile( h ), "LoadHouseData", .bExtra = true, .extra = h );
            printf("ID: %d, VW: %d", houID [ h ], houStats [ h ] [ EnterVirtualWorldID ] );
        }
    }
    return true;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)