Trying to write /reports to file
#10

I changed back to:
Код:
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);

}
Can anyone figure out why it wont write to a file?
Reply


Messages In This Thread
Trying to write /reports to file - by Brandondw8 - 14.05.2014, 19:53
Re: Trying to write /reports to file - by KillerStrike23 - 14.05.2014, 19:58
Re: Trying to write /reports to file - by Brandondw8 - 14.05.2014, 20:03
Re: Trying to write /reports to file - by Brandondw8 - 14.05.2014, 20:07
Re: Trying to write /reports to file - by awsomedude - 14.05.2014, 21:00
Re: Trying to write /reports to file - by Brandondw8 - 14.05.2014, 23:28
Re: Trying to write /reports to file - by Brandondw8 - 15.05.2014, 00:32
Re: Trying to write /reports to file - by KillerStrike23 - 15.05.2014, 03:47
Re: Trying to write /reports to file - by Brandondw8 - 15.05.2014, 04:42
Re: Trying to write /reports to file - by Brandondw8 - 15.05.2014, 07:45

Forum Jump:


Users browsing this thread: 1 Guest(s)