InGame Chat log.
#1

Well i made function wich will show me chat log ingame, but ingame its show only first line, i want it to show last 100 lines.


Код HTML:
forward ReadChatLog(playerid);
public ReadChatLog(playerid)
{
    new string[64]; 
    new File:example = fopen("Logs/chat.log", io_read); 
    fread(example, string, 15000);
    fclose(example); 
	SendClientMessage(playerid, COLOR_GREEN, "CHAT LOGs:");
	SendClientMessage(playerid, COLOR_GREEN, string);
    return 1;
}

if(strcmp(cmd, "/ccl", true) == 0)
{
    if(PlayerInfo[playerid][pAdmin] >= 5)
    {
        ReadChatLog(playerid);
    }
    else
    {
        SendClientMessage(playerid, COLOR_GRAD1, "** You are not an admin!");
    }
    return 1;
}
Reply
#2

bump
Reply
#3

Try increasing the string, or add a new line "%s\n%\n
Reply
#4

PHP код:
#define MAX_LINES_SENT  20//we do this incase the log has 200 lines in it, you wouldn't want your screen spammed with 200 lines of chat would you?
forward ReadChatLog (playerid);
public 
ReadChatLog (playerid)
{
    new 
string [128],Fileexample fopen ("Logs / chat.log"io_read); 
    
    while(
fread(examplestring))
    {
        
        
line ++;
        
SendClientMessage (playeridCOLOR_GREEN"CHAT LOGs:");
    
SendClientMessage (playeridCOLOR_GREENstring);
        if(
line >= MAX_LINES_SENT)
        {
            break;
        }
    }
    
fclose(example);
    return 
1;

This hasn't been tested and may not compile(due to typos) . if this compiles but doesn't work be sure that you are adding \n at the end of the string in function that actually writes the log.
Reply
#5

Thanks will try it.
Reply
#6

Every thing works greate expect, when i do /ccl its read only first lines ( old one ) i want it to read last 25 files
Reply
#7

bump.
Reply
#8

bump
Reply
#9

is it because the command ccl?

i only make the commands.. [You Need ZCMD To Make This CMD Work]

pawn Код:
CMD:ccl(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 5)
    {
        ReadChatLog(playerid);
    }
    else
    {
        SendClientMessage(playerid, COLOR_GRAD1, "** You are not an admin!");
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)