03.07.2014, 13:12
Hello,so how do i make /reports command that reads the reports from a file (By File.inc) and sends a messages that it is showing the current reports,how can i do that?
#include <a_samp>
#include <zcmd>
#include <sscanf2>
stock Name(playerid)//stock to get player name
{
new name[24];
GetPlayerName(playerid, name, 24);
return name;
}
CMD:reprot(playerid, params[])
{
//first here do the checks if the player who playerid wants to report is connected or not
//now suppose that you store the playerid who is being reported in "targetid" and reason in "reason"
new str[128];
format(str,128,"%s|%s|%s",Name(playerid),Name(targetid),reason);
new File:file=fopen("Reports.txt", io_append);
fwrite(file, str);
fwrite(file, "\n\r");//this is to leave a line after writing
fclose(file);
return1;
}
CMD:checkreport(playerid params[])//comand to read the reports
{
//first check that the playerid is admin or not
new reporter[24],reported[24],reason[80],line[128],str[1000],temp[130];
new File:file=fopen("Reports.txt", io_read);
while(fread(file, line);
{
sscanf(line, "p<|>sss"reporter, reported, reason);//to split the line
format(temp, 130, "Reporter: %s || Player Reported: %s || reason: %s\n",reporter,reported,reason);
strcat(str, temp, 130);
}
fclose(file);
//now the reports have been stored in variable "str" show it using ShowPlayerDialog
return 1;
}