[Include] pLogs
#1

Bem, estou divulgando minha include de Logs agora que nгo a uso mais ( Sйrio, nгo diga!?? ), o que se pode fazer com ela:

Код:
- OBS: Feita em File Functions

- Funзгo: newLog(filename[])
Cria um novo log, caso jб exista retornarб um print no console informando.

- Funзгo: writeLog(filename[], text[])
Escreve uma informaзгo no arquivo especificado, ja informando data e horбrio, caso o arquivo nгo exista, й criado automaticamente.

- Funзгo: deleteLog(filename[])
Nгo hб muito o que dizer, deleta um log xD, se nгo existir o Log printa no console.

- Funзгo: printLog(filename[])
Dб print no console com todo o texto do arquivo

- Funзгo: readLog(playerid, color, filename[])
Permite ler Logs in-game, mostrando todo o conteъdo do arquivo a um jogador.
Source:

pawn Код:
#include <a_samp>

/*
native newLog(filename[]);
native writeLog(filename[], text[]);
native deleteLog(filename[]);
native printLog(filename[]);
native readLog(playerid, color, filename[]);
*/


stock newLog ( filename [ ] ) {
    if ( fexist ( filename ) )
        return printf ( "[ERRO]: O arquivo %s jб existe." , filename );
       
    return fclose ( fopen ( filename , io_write ) );
}

stock writeLog ( filename [ ] , text [ ] ) {
    new
        str [ 128 ],
        day,
        month,
        year,
        hour,
        minute,
        second,
        File: fileLog;
       
    if ( !fexist ( filename ) ) {
        newLog ( filename );
    }
       
    gettime ( hour , minute , second );
    getdate ( year , month , day );
   
    fileLog = fopen ( filename , io_append );
    format ( str , sizeof ( str ) , "[%02i/%02i/%04i - %02i:%02i:%02i]: %s\r\n" , day , month , year , hour , minute , second , text );
    fwrite ( fileLog , str );
    fclose ( fileLog );
    return 1;
}

stock deleteLog ( filename [ ] ) {
    if ( !fexist ( filename ) )
        return printf ( "[ERRO]: O arquivo %s nгo existe." , filename );
       
    return fremove ( filename );
}

stock printLog ( filename [ ] ) {
    new
        readString [ 128 ],
        File: logFile;

    if ( !fexist ( filename ) )
        return printf ( "[ERRO]: O arquivo %s nгo existe." , filename );
       
    logFile = fopen ( filename , io_read );
    while ( fread ( logFile , readString ) ) {
        printf ("\n[%s]: %s\n" , filename , readString );
    }
    return 1;
}

stock readLog ( playerid , color , filename [ ] ) {
    new
        str [ 128 ],
        readString [ 128 ],
        File: logFile;

    if ( !fexist ( filename ) )
        return format ( str , 70 , "[ERRO]: O arquivo %s nгo existe." , filename ) , SendClientMessage ( playerid , color , str );

    logFile = fopen ( filename , io_read );
    while ( fread ( logFile , readString ) ) {
        format ( str , sizeof str , "[%s]: %s" , filename , readString );
        SendClientMessage ( playerid , color , str );
    }
    return 1;
}
Download here!


Espero que possa ser ъtil.
Reply
#2

Legal, bem interessante! Vindo de vc esperava ser em mysql.
Reply
#3

wow, not bad rs.

@paulor
Acho que usar MySQL em um script tгo simples й perda de tempo, rs
Reply
#4

Quote:
Originally Posted by AFerreira
Посмотреть сообщение
wow, not bad rs.

@paulor
Acho que usar MySQL em um script tгo simples й perda de tempo, rs
Exatamente por isso fiz em File, se fosse em MySQL acho que poucos usariam..
Reply
#5

Bem legal, fiz um igual ao teu (:
Reply
#6

Obrigado
Reply
#7

Muito Bom .
Reply
#8

Obrigado
Reply
#9

Bom trabalho.
Reply
#10

Quote:
Originally Posted by paulor
Посмотреть сообщение
Legal, bem interessante! Vindo de vc esperava ser em mysql.
Dependendo, й possнvel usar em MySQL, mas tem que ser usado logicamente se nгo aquilo pode sair mal e estragar sua database

Gostei do trabalho, a tempos ninguйm sabia como fazer, hoje em dia jб sabem (:
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)