Question. -
Face9000 - 20.12.2010
Hi all,i maked this custom code for the ban function:
Код:
dcmd_b(playerid, params[])
{
if(PlayerInfo[playerid][AdminLevel] > 2)
{
new toplayerid, reason[ 128 ];
if (sscanf(params, "us[128]", toplayerid, reason))
{
SendClientMessage(playerid, 0xAA3333AA, "Syntax Error: /b < Playerid > < Reason >");
return 1;
}
if (toplayerid == INVALID_PLAYER_ID)
{
SendClientMessage(playerid, 0xAA3333AA, "Input Error: Player is not connected or it is yourself.");
return 1;
}
new banString[128], adminName[24], bannedName[24];
GetPlayerName(playerid, adminName, 24);
GetPlayerName(toplayerid, bannedName, 24);
format(banString, 128, "Player %s was banned by Administrator %s. Reason: %s.", bannedName, adminName, reason);
SendClientMessageToAll(0xAA3333AA, banString);
new str[100];
format(str,sizeof str,"0,4Player %s was banned by Administrator %s. Reason: %s", bannedName, adminName, reason);
IRC_GroupSay(gGroupID, IRC_CHANNEL, str);
BanLog(banString);
Ban(toplayerid);
}
return 1;
}
I need to add,when some admin ban a player,the name banned will be added to a file. (Ex: bannednames.txt)
Thanks.
Re: Question. -
blackwave - 20.12.2010
pawn Код:
dcmd_b(playerid, params[])
{
if(PlayerInfo[playerid][AdminLevel] > 2)
{
new toplayerid, reason[ 128 ];
new File:LAdminfile,filepath[256];
if (sscanf(params, "us[128]", toplayerid, reason))
{
SendClientMessage(playerid, 0xAA3333AA, "Syntax Error: /b < Playerid > < Reason >");
return 1;
}
if (toplayerid == INVALID_PLAYER_ID)
{
SendClientMessage(playerid, 0xAA3333AA, "Input Error: Player is not connected or it is yourself.");
return 1;
}
new banString[128], adminName[24], bannedName[24];
GetPlayerName(playerid, adminName, 24);
GetPlayerName(toplayerid, bannedName, 24);
format(banString, 128, "Player %s was banned by Administrator %s. Reason: %s.", bannedName, adminName, reason);
SendClientMessageToAll(0xAA3333AA, banString);
LAdminfile = fopen(filepath,io_append);
fwrite(LAdminfile,banString);
new str[100];
format(str,sizeof str,"0,4Player %s was banned by Administrator %s. Reason: %s", bannedName, adminName, reason);
IRC_GroupSay(gGroupID, IRC_CHANNEL, str);
BanLog(banString);
Ban(toplayerid);
fclose(LAdminfile);
}
return 1;
Re: Question. -
Face9000 - 20.12.2010
LAdminFile?..wtf?
Re: Question. -
blackwave - 20.12.2010
Quote:
Originally Posted by Logitech90
LAdminFile?..wtf?
|
... it's just a name. I copied it from a script...
Re: Question. -
Face9000 - 20.12.2010
Oh..
But that will save all the ban string,i need to save ONLY the banned name.
This is an example of the BanLog
pawn Код:
public BanLog(string[])
{
new entry[128];
format(entry, sizeof(entry), "%s\n",string);
new File:hFile;
hFile = fopen("/LOGS/bans.log", io_append);
fwrite(hFile, entry);
fclose(hFile);
}
Any way to edit for saving only the banned name?
Re: Question. -
Seven. - 20.12.2010
pawn Код:
stock SaveHappening(filename[],text[])
{
new File:Saving;
new filepath[256];
new string[256];
new year,month,day;
new hour,minute,second;
getdate(year,month,day);
gettime(hour,minute,second);
format(filepath,sizeof(filepath),"Logs/%s.txt",filename);
Saving = fopen(filepath,io_append);
format(string,sizeof(string),"[%02d/%02d/| %02d:%02d] %s\r\n",day,month,hour,minute,text);
fwrite(Saving,string);
fclose(Saving);
return 1;
}
To use,
pawn Код:
SaveHappening(banlog, str);
for example.
Re: Question. -
Face9000 - 20.12.2010
Umh,i need only to paste the stock in my gm,then adding
pawn Код:
SaveHappening(banlog, str);
On the ban command?
Re: Question. -
Face9000 - 20.12.2010
EDIT: I fixed in another way,just creating new string like BanLog.
Thanks anyway for help.