Quote:
Originally Posted by Jf
PHP Code:
CMD:clearbans(playerid)
{
if(!IsAuth(playerid, 6)) return NoAuth(playerid);
// Create the file on OnGameModeInit() using io_append instead of io_write. By doing this you don't need to check if the file exist before this command executes.
new
File:handle = fopen("bans.cfg", io_write), // io_write deletes the entire data in the file. No need to use fremove.
string[128];
if(handle) // Valid handle
{
fclose(handle); // Close the file. Data has been deleted.
format(string, sizeof(string), "AdmCmd: %s %s has cleared the ban list, therefore everyone has been unbanned.", RPARN(playerid), RPN(playerid));
Log("unban.log", string);
SendAMessage(1, string);
}
else // We must check this, just in case.
{
format(string, sizeof(string), "Admin %s %s tried to erase the data of ban.cfg. There's been an error while deleting the data.", RPARN(playerid), RPN(playerid));
Log("unban.log", string);
print(string);
SendClientMessage(playerid, -1, ">> There has been an error while deleting the ban file. Report the server's owner.");
}
return 1;
}
|
Modified it a bit but works, thanks