Thread: [Ajuda] D˙vidas Curtas #1
View Single Post
Old 12/06/2019, 01:59 AM   #8902
Cycle
Big Clucker
 
Cycle's Avatar
 
Join Date: Sep 2017
Location: \localhost
Posts: 90
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