SA-MP Forums Archive
Making /report Command Please Help. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Making /report Command Please Help. (/showthread.php?tid=267426)



Making /report Command Please Help. - HayZatic - 08.07.2011

I want to make a /report command and have it save into a Folder. I know it would be something like

Код:
COMMAND:report(playerid,params[]) {
    new
        name1[30],
        name2[30],
        id,
        text[128],
        reason[50];
    if(sscanf(params,"us",id,reason))
        return SendClientMessage(playerid,red,"USAGE: /report [id] [reason]");
    if(IsPlayerConnected(id)) {
        SendClientMessage(playerid,Green,"Your report has been sent to online admins.");
        for(new i = 0; i < MAX_PLAYERS; ++i) {
            if(IsPlayerConnected(i) && !IsPlayerNPC(i) && IsPlayerAdmin(i)) {
            GetPlayerName(playerid,name1,sizeof(name1));
            GetPlayerName(id,name2,sizeof(name2));
            new Hour,Minute,Second;
            gettime(Hour,Minute,Second);
            format(text,sizeof(text),"|| %d:%d:%d || [Report] | \"%s\" [%i] has reported \"%s\" [%i], reason: %s.",Hour,Minute,Second,name1,playerid,name2,id,reason);
            SendClientMessage(i,COLOR_WHITE,text);
            }
        }
    } else {
        return SendClientMessage(playerid,red,"Invalid ID");
    }
    return 1;
}
But How Would i make it Write into a Folder And into a .txt


Re: Making /report Command Please Help. - [GTA]AmericanGangster - 08.07.2011

i think make the /report cmd into a zcmd report or something strcmd!

btw nice job!


Re: Making /report Command Please Help. - HayZatic - 08.07.2011

Quote:
Originally Posted by TAGproduction
Посмотреть сообщение
i think make the /report cmd into a zcmd report or something strcmd!

btw nice job!
This is a ZCMD my freind


Re: Making /report Command Please Help. - Bu$ter - 08.07.2011

Try this (not sure does it work)

At the top of your script
pawn Код:
forward ReportLog(string[]);
next make:
pawn Код:
public ReportLog(string[])
{
    new entry[128];
    format(entry, sizeof(entry), "%s\n",string);
    new File:hFile;
    hFile = fopen("/Logs/Reports.log", io_append);
    fwrite(hFile, entry);
    fclose(hFile);
}
and edit your code:
pawn Код:
COMMAND:report(playerid,params[]) {
    new
        name1[30],
        name2[30],
        id,
        text[128],
        reason[50];
    if(sscanf(params,"us",id,reason))
        return SendClientMessage(playerid,red,"USAGE: /report [id] [reason]");
    if(IsPlayerConnected(id)) {
        SendClientMessage(playerid,Green,"Your report has been sent to online admins.");
        for(new i = 0; i < MAX_PLAYERS; ++i) {
            if(IsPlayerConnected(i) && !IsPlayerNPC(i) && IsPlayerAdmin(i)) {
            GetPlayerName(playerid,name1,sizeof(name1));
            GetPlayerName(id,name2,sizeof(name2));
            new Hour,Minute,Second;
            gettime(Hour,Minute,Second);
            format(text,sizeof(text),"|| %d:%d:%d || [Report] | \"%s\" [%i] has reported \"%s\" [%i], reason: %s.",Hour,Minute,Second,name1,playerid,name2,id,reason);
            SendClientMessage(i,COLOR_WHITE,text);
            ReportLog(text);
        }
        }
    } else {
        return SendClientMessage(playerid,red,"Invalid ID");
    }
    return 1;
}
Just remember to create folder called Logs


Re: Making /report Command Please Help. - [GTA]AmericanGangster - 08.07.2011

nice Bu$ter