[Ajuda] Include bCini (PROJETO BY EQUIPE COP)
#2

Nгo sei se vai ajudar, mais tente. Nгo sou bom nisso!

pawn Код:
stock bCini_SetarTexto( arquivo[],linha[],valor[] )
{
    if( strlen( linha ) == 0 || strlen( linha )+strlen( valor )+2 > 128 ) {
        return 0;
    }
    new
        File:File2,
        File:File3,
        bool:Set = true,
        File2 = fopen( arquivo,io_read );

    format( bCiniFiles, sizeof( bCiniFiles ), "%s", arquivo );
    fremove( bCiniFiles );

    if( !File2 ) {
        return 0;
    }
    while( fread(File2,bCiniFiles )) {
        if( !Set && bCiniFiles[ strlen( linha ) ] == '=' && !strcmp( bCiniFiles, linha, true, strlen( linha ))) {
            format( bCiniFiles, sizeof( bCiniFiles ),"%s=%s", linha, valor), Set = true;
        } else {
            NovaLinha( bCiniFiles );
        }
    }
    fwrite( File3,bCiniFiles );
    fwrite( File3, "\r\n" );

    if( !Set ) {
        format( bCiniFiles, sizeof( bCiniFiles ), "%s=%s", linha, valor ), fwrite( File3,bCiniFiles ), fwrite( File3, "\r\n" );
    }
    fclose( File2 ), fclose( File3 );
    return 0;
}
stock NovaLinha( linha[] ) {
    if( linha[ 0 ] == 0 ) {
        return 0;
    }
    if( linha[ strlen ( linha )-1 ] == '\n' || linha[ strlen ( linha )-1 ] == '\r') {
        linha[ strlen ( linha )-1 ] = 0;

        if( linha[0] == 0 ) {
            return 0;
        }
        if( linha[ strlen( linha )-2 ] == '\n' || linha[ strlen( linha)-2 ] == '\r' ) {
            linha[ strlen( linha )-2 ] = 0;
        }
    }
    return 1;
}
Reply


Messages In This Thread
Include bCini (PROJETO BY EQUIPE COP) - by BielCOP - 30.09.2013, 00:05
Re: Include bCini (PROJETO BY EQUIPE COP) - by Gleisson_. - 30.09.2013, 00:19
Re: Include bCini (PROJETO BY EQUIPE COP) - by BielCOP - 30.09.2013, 00:24
Re: Include bCini (PROJETO BY EQUIPE COP) - by Gleisson_. - 30.09.2013, 00:31
Re: Include bCini (PROJETO BY EQUIPE COP) - by BielCOP - 30.09.2013, 00:32
Re: Include bCini (PROJETO BY EQUIPE COP) - by ipsBruno - 30.09.2013, 00:33
Re: Include bCini (PROJETO BY EQUIPE COP) - by BielCOP - 30.09.2013, 00:38
Respuesta: Include bCini (PROJETO BY EQUIPE COP) - by SeV_ - 30.09.2013, 00:40
Re: Include bCini (PROJETO BY EQUIPE COP) - by BielCOP - 30.09.2013, 00:42
Re: Include bCini (PROJETO BY EQUIPE COP) - by ipsBruno - 30.09.2013, 00:52

Forum Jump:


Users browsing this thread: 3 Guest(s)