PDA

View Full Version : Saving an report into a .txt file at scriptfiles (+rep)


Trynda
20/05/2014, 11:32 AM
Hello there!!!

I just wanted to ask an HELP here, how do i build the /bugreport cmd? When you /bugreport <Description> your description will save on .txt file thanks in advance!

ATomas
20/05/2014, 11:34 AM
if(strcmp("/BugReport",cmdtext,true,10) == 0)
{
new File:log;
if(fexist("reports.txt")) log = fopen("reports.txt",io_append);
else log = fopen("reports.txt",io_write);
fwrite(log,cmdtext[11]);
fwrite(log,"\r\n");
fclose(log);
return 1;
}

Spartaaaaa
20/05/2014, 11:45 AM
if(strcmp("/BugReport",cmdtext,true,10) == 0)
{
new File:log;
if(fexist("reports.txt")) log = fopen("reports.txt",io_append);
else log = fopen("reports.txt",io_write);
fwrite(log,cmdtext[11]);
fwrite(log,"\r\n");
fclose(log);
return 1;
}

Yeaa... goto scriptfiles -> create reports.txt

Konstantinos
20/05/2014, 11:50 AM
@Above: Check the file handle otherwise you're going to have problems with server crashes and it's recommended NOT to use strcmp..


CMD:bugreport(playerid, params[])
{
if (isnull(params)) return SendClientMessage(playerid, -1, "Usage: /bugreport <Description>");

new
File: log = fopen("reports.txt", io_append);

if (!log) return SendClientMessage(playerid, -1, "Something went wrong. Please try reporting it later");

fwrite(log, params);
fwrite(log, "\r\n");
fclose(log);
return 1;
}

Threshold
20/05/2014, 11:59 AM
EDIT: I give up...

Trynda
20/05/2014, 12:32 PM
@Above: Check the file handle otherwise you're going to have problems with server crashes and it's recommended NOT to use strcmp..


CMD:bugreport(playerid, params[])
{
if (isnull(params)) return SendClientMessage(playerid, -1, "Usage: /bugreport <Description>");

new
File: log = fopen("reports.txt", io_append);

if (!log) return SendClientMessage(playerid, -1, "Something went wrong. Please try reporting it later");

fwrite(log, params);
fwrite(log, "\r\n");
fclose(log);
return 1;
}


thanks bro +Rep to all