public OnPlayerCommandText(playerid, cmdtext[]) { dcmd(parch, 5, cmdtext); dcmd(jetpack, 7, cmdtext); dcmd(report, 6, cmdtext); dcmd(randomcolor, 11, cmdtext); dcmd(stats, 5, cmdtext); dcmd(commands, 8, cmdtext); return 1; }
dcmd_report(playerid, params[]) { new tmp[256], idx; tmp = strtok(params, idx); if(!strlen(tmp)){ SendClientMessage(playerid, 0x555252AA, "/report [id] [reason]"); return 1; }else{ new pid = strval(tmp); tmp = strrest(params, idx); if(!IsPlayerConnected(pid)){ SendClientMessage(playerid, 0x555252AA, "Invalid Player"); return 1; }else{ if(!strlen(tmp)){ SendClientMessage(playerid, 0x555252AA, "/report [id] [reason]"); return 1; }else{ new name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME], string[200]; GetPlayerName(playerid, name, sizeof(name)); GetPlayerName(pid, name2, sizeof(name2)); format(string, sizeof(string), "*%s(%d) reported %s(%d) for '%s'", name, playerid, name2, pid, tmp); for(new i=0; i<GetMaxPlayers(); i++){ if(IsPlayerConnected(i)){ if(IsPlayerAdmin(i)){ SendClientMessage(i, 0x555252AA, string); } } } } } } return 1; }
stock WriteReportsLog(string[]) { if(!fexist("Reports.log")) dini_Create("Reports.log"); // You need to change dini_Create to your file creating system. new entry[255], File: hFile; format(entry, sizeof(entry), "%s\r\n", string); hFile = fopen("Reports.log", io_append); fwrite(hFile, entry); fclose(hFile); }
public SaveToFile(filename[],text[]){
#if defined SAVE_LOGS
new File:File filepath[128], string[128], year,month,day, hour,minute,second;
getdate(year,month,day); gettime(hour,minute,second);
format(filepath,sizeof(filepath),"Thepath/%s.txt",filename);
File = fopen(filepath,io_append);
format(string,sizeof(string),"[%d.%d.%d %d:%d:%d] %s\r\n",day,month,year,hour,minute,second,text);
fwrite(File,string);
fclose(File);
#endif
return 1;}
SaveToFile("Reports",string);
pawn Код:
PHP код:
|
public SaveToFile(filename[],text[]){
new File:File filepath[128], string[128], year,month,day, hour,minute,second;
public SaveToFile(filename[],text[]){ new File:File filepath[128], string[128], year,month,day, hour,minute,second; getdate(year,month,day); gettime(hour,minute,second); format(filepath,sizeof(filepath),"Thepath/%s.txt",filename); File = fopen(filepath,io_append); format(string,sizeof(string),"[%d.%d.%d %d:%d:%d] %s\r\n",day,month,year,hour,minute,second,text); fwrite(File,string); fclose(File); return 1;}
#define filepath "Reports/%s.ini"
new Reports[MAX_REPORTS][128];
#define MAX_REPORTS 7
dcmd_report(playerid, params[]) {
new reported, tmp[128], tmp2[128], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index);
if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /report [playerid] [reason]");
reported = strval(tmp);
if(IsPlayerConnected(reported) && reported != INVALID_PLAYER_ID) {
if(PlayerInfo[reported][Level] == ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot report this administrator");
if(playerid == reported) return SendClientMessage(playerid,red,"ERROR: You Cannot report yourself");
if(strlen(params) > 7) {
new reportedname[MAX_PLAYER_NAME], reporter[MAX_PLAYER_NAME], str[128], hour,minute,second; gettime(hour,minute,second);
GetPlayerName(reported, reportedname, sizeof(reportedname)); GetPlayerName(playerid, reporter, sizeof(reporter));
format(str, sizeof(str), "||NewReport|| %s(%d) reported %s(%d) Reason: %s |@%d:%d:%d|", reporter,playerid, reportedname, reported, params[strlen(tmp)+1], hour,minute,second);
MessageToAdmins(COLOR_WHITE,str);
SaveToFile("ReportLog",str);
format(str, sizeof(str), "Report(%d:%d:%d): %s(%d) reported %s(%d) Reason: %s", hour,minute,second, reporter,playerid, reportedname, reported, params[strlen(tmp)+1]);
for(new i = 1; i < MAX_REPORTS-1; i++) Reports[i] = Reports[i+1];
Reports[MAX_REPORTS-1] = str;
return SendClientMessage(playerid,yellow, "Your report has been sent to online administrators.");
} else return SendClientMessage(playerid,red,"ERROR: Must be a valid reason");
} else return SendClientMessage(playerid, red, "Player is not connected");}
forward MessageToAdmins(color,const string[]);
public MessageToAdmins(color,const string[]){
for(new i = 0; i < MAX_PLAYERS; i++){
if(IsPlayerConnected(i) == 1) if (PlayerInfo[i][Level] >= 1) SendClientMessage(i, color, string);}
return 1;}
if(IsPlayerConnected(i) == 1) if (PlayerInfo[i][Level] >= 1) SendClientMessage(i, color, string);}
public MessageToAdmins(color,const string[]){ for(new i = 0; i < MAX_PLAYERS; i++){ if(IsPlayerConnected(i) == 1) if (PlayerInfo[i][Level] >= 1) SendClientMessage(i, color, string);} return 1;}
dcmd_report(playerid, params[]) { #pragma unused params new tmp[256], idx; tmp = strtok(params, idx); if(!strlen(tmp)){ SendClientMessage(playerid, 0x555252AA, "/report [id] [reason]"); return 1; }else{ new pid = strval(tmp); tmp = strrest(params, idx); if(!IsPlayerConnected(pid)){ SendClientMessage(playerid, 0xFF0000AA, "Invalid Player"); return 1; }else{ if(!strlen(tmp)){ SendClientMessage(playerid, 0xFFFFFFAA, "/report [id] [reason]"); return 1; }else{ new name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME], string[200]; GetPlayerName(playerid, name, sizeof(name)); GetPlayerName(pid, name2, sizeof(name2)); format(string, sizeof(string), "*%s(%d) reported %s(%d) for '%s'", name, playerid, name2, pid, tmp); for(new i=0; i<GetMaxPlayers(); i++){ if(IsPlayerConnected(i)){ { SendClientMessage(i, 0x00FF00C8, string); SaveToFile("Reports",string); } } } } } } return 1; } public SaveToFile(filename[],text[]){ #if defined SAVE_LOGS new File:File filepath[128], string[128], year,month,day, hour,minute,second; getdate(year,month,day); gettime(hour,minute,second); format(filepath,sizeof(filepath),"Reports/%s.ini",filename); File = fopen(filepath,io_append); format(string,sizeof(string),"[%d.%d.%d %d:%d:%d] %s\r\n",day,month,year,hour,minute,second,text); fwrite(File,string); fclose(File); #endif return 1;}
stock WriteReportsLog(string[]) { if(!fexist("Reports.ini")) dini_Create("Reports.ini"); // You need to change dini_Create to your file creating system. new entry[255], File: hFile; format(entry, sizeof(entry), "%s\r\n", string); hFile = fopen("Reports.ini", io_append); fwrite(hFile, entry); fclose(hFile); }