Toy System (Not Saving Properly) +Rep
#10

Quote:
Originally Posted by Jefff
View Post
Change all formats in saving from
pawn Code:
format(var, 32, "tCreated[%d]=%d\r\n", x, ToyInfo[playerid][x][tCreated]);
to

pawn Code:
format(var, 32, "tCreated[x]=%d\r\n", ToyInfo[playerid][x][tCreated]);
all [%d] to [x] and remove all x,

and better loading

pawn Code:
forward LoadToys(playerid);
public LoadToys(playerid)
{
    new stringtoy[55];
    format(stringtoy, sizeof(stringtoy), "South-WestRP/PlayerToys/%s.ini", GetPlayerNameEx(playerid));

    new File:example = fopen(stringtoy, io_read);
    if(!example) return 0;

    new key[ 15 ] , Data[ 256 ];
    for(new x = 0; x < MAX_TOYS; x++)
    {
        while ( fread( example , Data ) )
        {
            strcat( ( key[0] = '\0', key ), ini_GetKey( Data ), sizeof( key ) );
            if( strcmp( key , "tCreated[x]" , true ) == 0 ) ToyInfo[playerid][x][tCreated] = strval( ini_GetValue( Data ) );
            if( strcmp( key , "tEquipped[x]" , true ) == 0 ) ToyInfo[playerid][x][tEquipped] = strval( ini_GetValue( Data ) );
            if( strcmp( key , "tName[x]" , true ) == 0 ) strcat( ( ToyInfo[playerid][x][tName][0] = '\0', ToyInfo[playerid][x][tName] ), ini_GetValue( Data ), 128 );
            if( strcmp( key , "tIndexID[x]" , true ) == 0 ) ToyInfo[playerid][x][tIndexID] = strval( ini_GetValue( Data ) );
            if( strcmp( key , "tModelID[x]" , true ) == 0 ) ToyInfo[playerid][x][tModelID] = strval( ini_GetValue( Data ) );
            if( strcmp( key , "tBoneID[x]" , true ) == 0 ) ToyInfo[playerid][x][tBoneID] = strval( ini_GetValue( Data ) );
            if( strcmp( key , "tOffsetX[x]" , true ) == 0 ) ToyInfo[playerid][x][tOffsetX] = floatstr( ini_GetValue( Data ) ); // Line 5125
            if( strcmp( key , "tOffsetY[x]" , true ) == 0 ) ToyInfo[playerid][x][tOffsetY] = floatstr( ini_GetValue( Data ) );
            if( strcmp( key , "tOffsetZ[x]" , true ) == 0 ) ToyInfo[playerid][x][tOffsetZ] = floatstr( ini_GetValue( Data ) );
            if( strcmp( key , "tRotX[x]" , true ) == 0 ) ToyInfo[playerid][x][tRotX] = floatstr( ini_GetValue( Data ) );
            if( strcmp( key , "tRotY[x]" , true ) == 0 ) ToyInfo[playerid][x][tRotY] = floatstr( ini_GetValue( Data ) );
            if( strcmp( key , "tRotZ[x]" , true ) == 0 ) ToyInfo[playerid][x][tRotZ] = floatstr( ini_GetValue( Data ) );
            if( strcmp( key , "tScaleX[x]" , true ) == 0 ) ToyInfo[playerid][x][tScaleX] = floatstr( ini_GetValue( Data ) );
            if( strcmp( key , "tScaleY[x]" , true ) == 0 ) ToyInfo[playerid][x][tScaleY] = floatstr( ini_GetValue( Data ) );
            if( strcmp( key , "tScaleZ[x]" , true ) == 0 ) ToyInfo[playerid][x][tScaleZ] = floatstr( ini_GetValue( Data ) ); // Line 5133
        }
    }
    return fclose(example);
}
I changed like you said but it's still not loading

pawn Code:
forward SaveToys(playerid);
public SaveToys(playerid)
{
    if(IsPlayerConnected(playerid) && PLogged[playerid])
    {
        new stringtoy[55], var[32];
        format(stringtoy, sizeof(stringtoy), "South-WestRP/PlayerToys/%s.ini", GetPlayerNameEx(playerid));
        new File: hFile = fopen(stringtoy, io_write);
        if(!hFile) return 0;
        for(new x = 0; x < MAX_TOYS; x++)
        {
            format(var, 32, "tCreated[x]=%d\r\n", ToyInfo[playerid][x][tCreated]);
            fwrite(hFile, var);
            format(var, 32, "tEquipped[x]=%d\r\n", ToyInfo[playerid][x][tEquipped]);
            fwrite(hFile, var);
            format(var, 32, "tName[x]=%s\r\n", ToyInfo[playerid][x][tName]);
            fwrite(hFile, var);
            format(var, 32, "tIndexID[x]=%d\r\n", ToyInfo[playerid][x][tIndexID]);
            fwrite(hFile, var);
            format(var, 32, "tModelID[x]=%d\r\n", ToyInfo[playerid][x][tModelID]);
            fwrite(hFile, var);
            format(var, 32, "tBoneID[x]=%d\r\n", ToyInfo[playerid][x][tBoneID]);
            fwrite(hFile, var);
            format(var, 32, "tOffsetX[x]=%f\r\n", ToyInfo[playerid][x][tOffsetX]);
            fwrite(hFile, var);
            format(var, 32, "tOffsetY[x]=%f\r\n", ToyInfo[playerid][x][tOffsetY]);
            fwrite(hFile, var);
            format(var, 32, "tOffsetZ[x]=%f\r\n", ToyInfo[playerid][x][tOffsetZ]);
            fwrite(hFile, var);
            format(var, 32, "tRotX[x]=%f\r\n", ToyInfo[playerid][x][tRotX]);
            fwrite(hFile, var);
            format(var, 32, "tRotY[x]=%f\r\n", ToyInfo[playerid][x][tRotY]);
            fwrite(hFile, var);
            format(var, 32, "tRotZ[x]=%f\r\n", ToyInfo[playerid][x][tRotZ]);
            fwrite(hFile, var);
            format(var, 32, "tScaleX[x]=%f\r\n", ToyInfo[playerid][x][tScaleX]);
            fwrite(hFile, var);
            format(var, 32, "tScaleY[x]=%f\r\n", ToyInfo[playerid][x][tScaleY]);
            fwrite(hFile, var);
            format(var, 32, "tScaleZ[x]=%f\r\n", ToyInfo[playerid][x][tScaleZ]);
            fwrite(hFile, var);
        }
        fclose(hFile);
        return 1;
    }
    return 0;
}

forward LoadToys(playerid);
public LoadToys(playerid)
{
    new stringtoy[55];
    format(stringtoy, sizeof(stringtoy), "South-WestRP/PlayerToys/%s.ini", GetPlayerNameEx(playerid));

    new File:example = fopen(stringtoy, io_read);
    if(!example) return 0;

    new key[ 15 ] , Data[ 256 ];
    for(new x = 0; x < MAX_TOYS; x++)
    {
        while ( fread( example , Data ) )
        {
            strcat( ( key[0] = '\0', key ), ini_GetKey( Data ), sizeof( key ) );
            if( strcmp( key , "tCreated[x]" , true ) == 0 ) ToyInfo[playerid][x][tCreated] = strval( ini_GetValue( Data ) );
            if( strcmp( key , "tEquipped[x]" , true ) == 0 ) ToyInfo[playerid][x][tEquipped] = strval( ini_GetValue( Data ) );
            if( strcmp( key , "tName[x]" , true ) == 0 ) strcat( ( ToyInfo[playerid][x][tName][0] = '\0', ToyInfo[playerid][x][tName] ), ini_GetValue( Data ), 128 );
            if( strcmp( key , "tIndexID[x]" , true ) == 0 ) ToyInfo[playerid][x][tIndexID] = strval( ini_GetValue( Data ) );
            if( strcmp( key , "tModelID[x]" , true ) == 0 ) ToyInfo[playerid][x][tModelID] = strval( ini_GetValue( Data ) );
            if( strcmp( key , "tBoneID[x]" , true ) == 0 ) ToyInfo[playerid][x][tBoneID] = strval( ini_GetValue( Data ) );
            if( strcmp( key , "tOffsetX[x]" , true ) == 0 ) ToyInfo[playerid][x][tOffsetX] = floatstr( ini_GetValue( Data ) ); // Line 5125
            if( strcmp( key , "tOffsetY[x]" , true ) == 0 ) ToyInfo[playerid][x][tOffsetY] = floatstr( ini_GetValue( Data ) );
            if( strcmp( key , "tOffsetZ[x]" , true ) == 0 ) ToyInfo[playerid][x][tOffsetZ] = floatstr( ini_GetValue( Data ) );
            if( strcmp( key , "tRotX[x]" , true ) == 0 ) ToyInfo[playerid][x][tRotX] = floatstr( ini_GetValue( Data ) );
            if( strcmp( key , "tRotY[x]" , true ) == 0 ) ToyInfo[playerid][x][tRotY] = floatstr( ini_GetValue( Data ) );
            if( strcmp( key , "tRotZ[x]" , true ) == 0 ) ToyInfo[playerid][x][tRotZ] = floatstr( ini_GetValue( Data ) );
            if( strcmp( key , "tScaleX[x]" , true ) == 0 ) ToyInfo[playerid][x][tScaleX] = floatstr( ini_GetValue( Data ) );
            if( strcmp( key , "tScaleY[x]" , true ) == 0 ) ToyInfo[playerid][x][tScaleY] = floatstr( ini_GetValue( Data ) );
            if( strcmp( key , "tScaleZ[x]" , true ) == 0 ) ToyInfo[playerid][x][tScaleZ] = floatstr( ini_GetValue( Data ) ); // Line 5133
        }
    }
    return fclose(example);
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)