SA-MP Forums Archive
[Include] pLogs - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+----- Forum: Lançamentos/Releases (https://sampforum.blast.hk/forumdisplay.php?fid=56)
+----- Thread: [Include] pLogs (/showthread.php?tid=332889)



pLogs - Jason` - 09.04.2012

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.



Re: pLogs - paulor - 09.04.2012

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


Re: pLogs - Abravanel - 09.04.2012

wow, not bad rs.

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


Re: pLogs - Jason` - 09.04.2012

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..


Re: pLogs - [R] ousenber [K] - 09.04.2012

Bem legal, fiz um igual ao teu (:


Re: pLogs - Jason` - 09.04.2012

Obrigado


Respuesta: pLogs - [NVC]iTrevaS - 09.04.2012

Muito Bom .


Re: pLogs - Jason` - 09.04.2012

Obrigado


Re: pLogs - Đeagle - 09.04.2012

Bom trabalho.


Re: pLogs - RebeloX - 09.04.2012

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 (: