SA-MP Forums

Go Back   SA-MP Forums > Non-English > Languages > Português/Portuguese

Reply
 
Thread Tools Display Modes
Old 09/06/2019, 09:01 PM   #8901
israelStaff
Little Clucker
 
Join Date: Aug 2017
Posts: 36
Reputation: 0
Default Re: Dúvidas Curtas #1

Estou fazendo um sistema de logs in-game, como faço para ler as ultimas 10 ou 50 linhas de um arquivo ?

pawn Code:
CMD:AvisoAdmin(playerid)
{
      MEGAString[0] = EOS;
      new str[128], readString[128], File:logFile;
      logFile = fopen("Logs/AvisoAdmin.log", io_read);
      strcat(MEGAString,"Logs de início de combate (Aviso dos administradores)\n\n");
      while(fread(logFile, readString)) {
        format(str, sizeof str, "%s", readString);
        strcat(MEGAString,str);
      }
      ShowPlayerDialog(playerid, 19989, DIALOG_STYLE_MSGBOX, "Log De Avisos", MEGAString, "Fechar", "");
      return 1;
}

estou utilizando esse comando como base.
israelStaff is offline   Reply With Quote
Old 12/06/2019, 01:59 AM   #8902
Cycle
Big Clucker
 
Cycle's Avatar
 
Join Date: Sep 2017
Location: Salvador, Brazil Discord: Diogo#7197
Posts: 88
Reputation: 91
Default Re: Dúvidas Curtas #1

Quote:
Originally Posted by israelStaff View Post
Estou fazendo um sistema de logs in-game, como faço para ler as ultimas 10 ou 50 linhas de um arquivo ?

pawn Code:
CMD:AvisoAdmin(playerid)
{
      MEGAString[0] = EOS;
      new str[128], readString[128], File:logFile;
      logFile = fopen("Logs/AvisoAdmin.log", io_read);
      strcat(MEGAString,"Logs de início de combate (Aviso dos administradores)\n\n");
      while(fread(logFile, readString)) {
        format(str, sizeof str, "%s", readString);
        strcat(MEGAString,str);
      }
      ShowPlayerDialog(playerid, 19989, DIALOG_STYLE_MSGBOX, "Log De Avisos", MEGAString, "Fechar", "");
      return 1;
}

estou utilizando esse comando como base.
try dat, idk if can be right, i'm far from SA:MP.
PHP Code:
GetLineFromFile(fileName[], numberLinebool:typeLog falseplayerid = -1)
{
    if(!
fexist(fileName))
        return 
printf("[GetLineFromFile]: There is something wrong, the file \"%s\" doesn't exist."fileName);

    new 
        
File:file fopen(fileNameio_read),
        
str[2][128],
        
numberOfLine[22],
        
countLine
    
;

    while(
fread(filestr[0]))
    {
        
countLine++;
        if(
countLine == numberLine)
            
strcat(str[1], str[0]);
    }

    
format(numberOfLinesizeof(numberOfLine), "[GetLineFromFile]: %d"numberLine);
    
strins(str[1], numberOfLine0);
    if(
typeLog)
    {
        if(
playerid != -1)
            
SendClientMessage(playerid, -1str[1]);
        else
        {
            for(new 
0GetPlayerPoolSize(); <= ji++)
            {
                if(
IsPlayerAdmin(i))
                {
                    
SendClientMessage(i, -1str[1]);
                }
            }
        }
    }
    else
        print(
str[1]);
    return
        
fclose(file);

Cycle is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Ajuda] Dúvidas, dúvidas e mais dúvidas. Mito_FmZ Português/Portuguese 6 30/07/2012 04:42 AM
[DUVIDAS] Duvidas sobre GM Waldrey Português/Portuguese 3 01/06/2012 02:56 PM
[Duvidas]Algumas duvidas. Felipe_Wesker Português/Portuguese 11 07/05/2012 08:31 PM
[DUVIDAS] matheuzinho Português/Portuguese 3 29/09/2010 10:07 PM
[DUVIDAS] Como faço isto?? (várias duvidas) andmeida10 Português/Portuguese 3 18/03/2010 09:06 AM


All times are GMT. The time now is 11:58 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.