Saving an report into a .txt file at scriptfiles (+rep)
#1

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!
Reply
#2

pawn Код:
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;
}
Reply
#3

Код:
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
Reply
#4

@Above: Check the file handle otherwise you're going to have problems with server crashes and it's recommended NOT to use strcmp..

pawn Код:
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;
}
Reply
#5

EDIT: I give up...
Reply
#6

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
@Above: Check the file handle otherwise you're going to have problems with server crashes and it's recommended NOT to use strcmp..

pawn Код:
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
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)