reports command problem and help
#1

This command works but it shows all reports i only want to show last 5 reports

Код:
CMD:reports(playerid,params[])
{
	new string[512];
	if(PInfo[playerid][Level] < 1)
    return SendClientMessage(playerid,STEALTH_BLUE,"You need to be level 1 to check reports.");
   	new File:rFile;
    rFile = fopen("Reports/Report.txt",io_read);
    while(fread(rFile,string,sizeof string, false))
    {
        format(string,sizeof(string),"%s",string);
		SendClientMessage(playerid,COLOR_MENUHIGHLIGHT,string);
    }
	fclose(rFile);
	return 1;
}
Reply
#2

Write it like this:

PHP код:
CMD:reports(playerid,params[])
{
    new 
string[512];
    if(
PInfo[playerid][Level] < 1) return SendClientMessage(playerid,STEALTH_BLUE,"You need to be level 1 to check reports.");
    if(!
fexist("Reports/Report.txt")) return SendClientMessage(playerid,STEALTH_BLUE,"The report file doesn't exist!");
    new 
File:fopen("Reports/Report.txt",io_read),counter,i;
    while(
fread(f,string)) counter++;
    
fclose(f),f=fopen("Reports/Report.txt",io_read);
    while(
fread(f,string,sizeof stringfalse))
    {
        if(
>= (counter-0x5)) SendClientMessage(playerid,COLOR_MENUHIGHLIGHT,string);
        
i++;
    }
    
fclose(f);
    return 
1;

Greekz
Reply
#3

Код:
CMD:reports(playerid,params[])
{
	new string[512];
	if(PInfo[playerid][Level] < 1)
    return SendClientMessage(playerid,STEALTH_BLUE,"You need to be level 1 to check reports.");
   	new File:rFile = fopen("Reports/Report.txt",io_read),counter,i;
   	while(fread(rFile,string)) counter++;
    fclose(rFile),rFile=fopen("Reports/Report.txt",io_read);
    while(fread(rFile,string,sizeof string, false)) counter++;
    {
        if(i >= (counter-0x5))
		format(string,sizeof(string),"%s",string);
		SendClientMessage(playerid,COLOR_MENUHIGHLIGHT,string);
		i++;
    }
	fclose(rFile);
	return 1;
}
not working
Reply
#4

So difficult to copy paste?

If you want to use format, write it like this:

Код:
CMD:reports(playerid,params[])
{
    new string[512];
    if(PInfo[playerid][Level] < 1) return SendClientMessage(playerid,STEALTH_BLUE,"You need to be level 1 to check reports.");
    new File:rFile = fopen("Reports/Report.txt",io_read),counter,i;
    while(fread(rFile,string)) counter++;
    fclose(rFile),rFile=fopen("Reports/Report.txt",io_read);
    while(fread(rFile,string,sizeof string, false))
    {
        if(i >= (counter-0x5))
        {
            format(string,sizeof(string),"%s",string);
	    SendClientMessage(playerid,COLOR_MENUHIGHLIGHT,string);
	}
        i++;
    }
    fclose(rFile);
    return 1;
}
Reply
#5

thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)