22.12.2015, 11:52
Currently, I use a ban and kick system like this.
I'd like to have a cmd like /searchkick and /searchban where an admin can do /searchban NAME/PartofName and then the server will search through the file, sending them a message with the ban/kick reason(s) they have on that account. Is this possible? IF so, I need assistance with creating this system.
Код:
forward BanLog(string[]);
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);
}
forward KickLog(string[]);
public KickLog(string[])
{
new entry[128];
format(entry, sizeof(entry), "%s\n",string);
new File:hFile;
hFile = fopen("/LOGS/kicks.log", io_append);
fwrite(hFile, entry);
fclose(hFile);
}
CMD:ban(playerid, params[])
{
if(pInfo[playerid][Adminlevel] >= 1) {
new toplayerid, reason[ 128 ];
if (sscanf(params, "us[128]", toplayerid, reason))
{
SendClientMessage(playerid, 0xAA3333AA, "Syntax Error: /ban < 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, "%s has been banned by Administrator %s. Reason: %s.", bannedName, adminName, reason);
SendClientMessageToAll(0xAA3333AA, banString);
BanLog(banString);
Ban(toplayerid);
}
return 1;
}
CMD:kick(playerid, params[])
{
if(pInfo[playerid][Adminlevel] >= 1) {
new toplayerid, reason[ 128 ];
if (sscanf(params, "us[128]", toplayerid, reason))
{
SendClientMessage(playerid, 0xAA3333AA, "Syntax Error: /kicktest < 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, "%s has been kicked by Administrator %s. Reason: %s.", bannedName, adminName, reason);
SendClientMessageToAll(0xAA3333AA, banString);
KickLog(banString);
Kick(toplayerid);
}
return 1;
}
I'd like to have a cmd like /searchkick and /searchban where an admin can do /searchban NAME/PartofName and then the server will search through the file, sending them a message with the ban/kick reason(s) they have on that account. Is this possible? IF so, I need assistance with creating this system.

