Gettime problem -
Nabster - 06.03.2015
The time is not loading,when i use /reports it doesn't show me log i tried removing gettime and it worked fine,what is the problem?
Код:
CMD:report(playerid,params[])
{
new string[256],reason[124],targetid,pName[MAX_PLAYER_NAME],pName1[MAX_PLAYER_NAME];
new reportstring[128],pIP[16];
new Hour,Minute,Second;
if(sscanf(params,"us[128]",targetid,reason))
return SendClientMessage(playerid,STEALTH_ORANGE,"USAGE: /report [id] [reason]");
if(!IsPlayerConnected(targetid))
return SendClientMessage(playerid,STEALTH_BLUE,"That player is not connected!");
GetPlayerName(playerid,pName,sizeof pName);
GetPlayerName(targetid,pName1,sizeof pName1);
GetPlayerIp(targetid,pIP,sizeof pIP);
gettime(Hour,Minute,Second);
format(reportstring,sizeof(reportstring),"{FF0000}[NEW REPORT] [%02d:%02d:%02d] {3399FF}Player %s(%d) has reported %s(%d) || %s || for {FF0000}%s.",Hour,Minute,Second,pName,playerid,pName1,targetid,pIP,reason);
MessageToAdmins(COLOR_MENUHIGHLIGHT,reportstring);
format(string,sizeof(string),"{3399FF}You have reported %s(%d) for {FF0000}%s {3399FF}our admins will check it asap.",pName,targetid,reason);
SendClientMessage(playerid,COLOR_MENUHIGHLIGHT,string);
ReportLog(reportstring);
GotReported = targetid;
SentReport = playerid;
return 1;
}
CMD:reports(playerid,params[])
{
new reportstring[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,reportstring)) counter++;
fclose(rFile),rFile=fopen("Reports/Report.txt",io_read);
SendClientMessage(playerid,COLOR_MENUHIGHLIGHT,"------------------------[ LATEST REPORTS ]------------------------");
while(fread(rFile,reportstring,sizeof reportstring, false))
{
if(i >= (counter-0x5))
{
format(reportstring,sizeof(reportstring),"%s",reportstring);
SendClientMessage(playerid,COLOR_MENUHIGHLIGHT,reportstring);
}
i++;
}
fclose(rFile);
return 1;
}
Re: Gettime problem -
X337 - 06.03.2015
I think the length of the string is the problem.
Код:
new reportstring[128],pIP[16];
to :
Код:
new reportstring[256],pIP[16];
Re: Gettime problem -
Nabster - 06.03.2015
It worked but not as i wanted to
In reports.txt it saved together in a line not in a new line earlier when i didn't use gettime it always saved on a new line like this
{0000}[NEW REPORT] [09:04:09] {3399FF}Player xxx(0) has reported xxx(0) || 1111111 || for {FF0000}testing3
{0000}[NEW REPORT] [09:04:09] {3399FF}Player xxx(0) has reported xxx(0) || 1111111 || for {FF0000}testing4
but now its all together in one line
this is my reportlog
Код:
forward ReportLog(reportstring[]);
public ReportLog(reportstring[])
{
new entry[128];
format(entry,sizeof(entry),"%s\r\n",reportstring);
new File:rFile;
rFile = fopen("Reports/Report.txt",io_append);
fwrite(rFile,entry);
fclose(rFile);
}
Re: Gettime problem -
X337 - 06.03.2015
What about this
Код:
forward ReportLog(reportstring[]);
public ReportLog(reportstring[])
{
new entry[150];
format(entry,sizeof(entry),"%s\r\n",reportstring);
new File:rFile;
rFile = fopen("Reports/Report.txt",io_append);
fwrite(rFile,entry);
fclose(rFile);
}
Re: Gettime problem -
Nabster - 06.03.2015
lol it was all lengths that was making it go wrong ,thank you for your help