SA-MP Forums Archive
[Include] Logs Dinвmicos! [Losgs] - 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] Logs Dinвmicos! [Losgs] (/showthread.php?tid=293534)



Logs Dinвmicos! [Losgs] - Lуs - 29.10.2011

Olб. Estava pensando em criar alguma coisa dinвmica hoje e resolvi fazer isso.

Vantagens: Natives:
pawn Код:
native CreateLog(const File[]);
native WriteLog(const File[], string[]);
native RemoveLog(const File[]);
native LogExists(const File[]);
Informaзхes: Exemplo de uso:

pawn Код:
public OnGameModeInit ( )
{
    new
        Log [ ] = "Logs/Server.log";//Cria uma array para armazenar o caminho do arquivo

    WriteLog ( Log, "Servidor iniciado" );//Escreve no arquivo da array.

    return 1;
}
Output: (18/05/2013)[14:20:39] Servidor iniciado

pawn Код:
public OnPlayerConnect ( playerid )
{
    new
        Log [ ] = "Log/users.log",
        str_log [ 128 ],
        str_plr_name [ MAX_PLAYER_NAME ];

    GetPlayerName ( playerid, str_plr_name, MAX_PLAYER_NAME );

    format ( str_log, sizeof ( str_log ), "O jogador %s se conectou ao servidor.", str_plr_name );
    WriteLog ( Log, str_log );

    return 1;
}
Output: (18/05/2013)[14:25:40] O jogador Los se conectou ao servidor.

pawn Код:
public OnGameModeInit ( )
{
    new
        Log [ ] = "Logs/Server.log";

    RemoveLog ( Log );//Exclui o arquivo, caso nгo exista irб retornar uma mensagem o console

    return 1;
}
pawn Код:
public OnGameModeInit ( )
{
    new
        Log [ ] = "Logs/Server.log";

    if ( !LogExists ( Log ) )//Verifica se o log existe
        CreateLog ( Log );//Cria o log

    //Lembre-se que a funзгo WriteLog automaticamente cria o log
    //caso ele nгo exista.

    WriteLog ( Log, "Servidor iniciado" );

    return 1;
}
Download:

Pastebin

Changelog:
Quote:
29/10/2011
  • Release inicial
18/05/2013
  • Foram feitas optimizaзхes em geral na include.
  • Alteraзгo da sintaxe.
  • Agora nгo й preciso criar um log antes de escreve-lo, quando for escrever automaticamente й criado.
  • Retirado a funзгo de ler o log.
  • Alterado mensagens de alerta no console.
05/07/2013
  • Reduzido o tamanho do script
  • Stock LogExistir foi alterada para macro
  • Pequenas alteraзхes na sintaxe



Re: Logs Dinвmicos! [Losgs] - Laercio - 29.10.2011

1є Post , UP , Bela Trabalho ADOREI '-'


Re: Logs Dinвmicos! [Losgs] - Hardware - 29.10.2011

Ficou bom, gostei. Sу foi tenso porque um deu um tutorial de como criar sistema de logs, no tуpico dele mostrar outro jeito e agora tu posta uma include de logs. UHEUHUEUEHEH
Um atrбs do outro. HEUHUEEUHe


Re: Logs Dinвmicos! [Losgs] - [O.z]Caroline - 29.10.2011

legal include...

pawn Код:
DeletarLog(const File[])
{
    if(!fexist(File))
    {
        printf("Esse arquivo nгo existe, utilize CriarLog(\"arquivo\"");
        return 0;
    }
    fremove(File);
    return 1;
}



Re: Logs Dinвmicos! [Losgs] - CanTLoGin - 29.10.2011

muito bom. vai me ajuda muito. rs.


Re: Logs Dinвmicos! [Losgs] - Lуs - 29.10.2011

Quote:
Originally Posted by [O.z]Caroline
Посмотреть сообщение
legal include...

pawn Код:
DeletarLog(const File[])
{
    if(!fexist(File))
    {
        printf("Esse arquivo nгo existe, utilize CriarLog(\"arquivo\"");
        return 0;
    }
    fremove(File);
    return 1;
}
Й que eu tava testando uma coisa. Obrigado *-*

Quote:
Originally Posted by Laercio
Посмотреть сообщение
1є Post , UP , Bela Trabalho ADOREI '-'
Quote:
Originally Posted by Hardware
Посмотреть сообщение
Ficou bom, gostei. Sу foi tenso porque um deu um tutorial de como criar sistema de logs, no tуpico dele mostrar outro jeito e agora tu posta uma include de logs. UHEUHUEUEHEH
Um atrбs do outro. HEUHUEEUHe
Quote:
Originally Posted by CanTLoGin
Посмотреть сообщение
muito bom. vai me ajuda muito. rs.
Valeu pessoal


Re: Logs Dinвmicos! [Losgs] - ViniBorn - 29.10.2011

Bom trabalho


Re: Logs Dinвmicos! [Losgs] - [O.z]Caroline - 29.10.2011

dica, para nгo der "Symbol never used" coloque "stock" antes da funзгo, exemplo:

pawn Код:
stock CriarLog(const File[])



Re: Logs Dinвmicos! [Losgs] - Lуs - 29.10.2011

Quote:
Originally Posted by [O.z]Caroline
Посмотреть сообщение
dica, para nгo der "Symbol never used" coloque "stock" antes da funзгo, exemplo:

pawn Код:
stock CriarLog(const File[])
Obrigado pela dica, atualizado!


Quote:
Originally Posted by Viniborn
Посмотреть сообщение
Bom trabalho
Vlw


Re: Logs Dinвmicos! [Losgs] - RebeloX - 29.10.2011

O meu й mais simples, rs.

pawn Код:
stock LogSystem(LogName[],Text[])
{
    new entry[128],other[128];
    format(entry,sizeof(entry), "%s\r\n",Text);
    format(other,sizeof(other), Logs,LogName);
    new File:hFile;
    hFile = fopen(other,io_append);
    fwrite(hFile, entry);
    fclose(hFile);

}
Bom trabalho mesmo assim x)