15.05.2014, 07:45
I changed back to:
Can anyone figure out why it wont write to a file?
Код:
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); }