Adding stuff to another file. - 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)
+--- Thread: Adding stuff to another file. (
/showthread.php?tid=299533)
Adding stuff to another file. -
Vic1990 - 26.11.2011
How would I add something to Scriptfiles/Logs/ban.log ? I know it'd be something like /Logs/ban.log but how would I add it to
Код:
CMD:ban(playerid, params[])
{
new
string[128],
giveplayerid,
adminname[MAX_PLAYER_NAME],
playername[MAX_PLAYER_NAME],
reason[50];
if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COL_GREY, "You are not authorized for that command!");
else if(sscanf(params, "rs[50]", giveplayerid, reason)) return SendClientMessage(playerid, COL_GREY, "Usage: /ban [ID/PartOfName] [Reason]");
else if(!IsPlayerConnected(giveplayerid) || giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COL_GREY, "Invalid playerid!");
else {
format(string, sizeof(string), "SERVER: %s have been banned by %s, reason: %s.", playername, adminname, reason);
SendClientMessageToAll(0xF81414FF, string);
Kick(giveplayerid);
}
return 1;
}
so that when you get /ban'ned it adds it to ban.log?
Re: Adding stuff to another file. -
Unte99 - 26.11.2011
https://sampwiki.blast.hk/wiki/Fwrite
Re: Adding stuff to another file. -
[MG]Dimi - 26.11.2011
PHP код:
new File:File,msg[128];
format(msg,128,">> %s have been banned by %s, reason: %s.\r\n", playername, adminname, reason);
File = fopen("Logs/ban.txt",io_append);
fwrite(File,msg);
fclose(File);