PHP код:
BanPlayer(playerid, bannerid, time[] = "PERMANENT", reason[] = "No Reason Given")
{
new query[256], ip[16], string[256];
UpdatePlayerData(playerid, 1);
GetPlayerIp(playerid, ip, 16);
mysql_format(g_SQL, query, sizeof(query), "DROP EVENT IF EXISTS `%e`", GetName(bannerid));
mysql_tquery(g_SQL, query);
mysql_format(g_SQL, query, sizeof(query), "INSERT INTO `bans`(`Username`, `BannedBy`, `BanReason`,`IpAddress`, `Date`) VALUES('%e', '%e', '%e', '%s', '%s')", GetName(playerid), GetName(bannerid), reason, ip, ReturnDate());
mysql_tquery(g_SQL, query);
//strreplaceEx(string[], const find[], const replace[], bool:ignorecase=true, count=cellmax, maxlength=sizeof(string))
//CREATE DEFINER=`root`@`localhost` EVENT `a` ON SCHEDULE AT '2018-12-19 15:09:43' ON COMPLETION NOT PRESERVE ENABLE DO DELETE FROM `bans` WHERE `Username` = 'Alfa_Sufa'
//CREATE DEFINER=`root`@`localhost` EVENT `Alfa_Sufa` ON SCHEDULE AT '2018-12-19 15:07:18' ON COMPLETION NOT PRESERVE ENABLE DO DELETE FROM `bans` WHERE `Username` = 'Alfa_Sufa'
if(strcmp(time, "PERMANENT", true))
{
mysql_format(g_SQL, query, sizeof(query), "CREATE EVENT `%e` ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL %s DO \
DELETE FROM `bans` WHERE `Username` = '%e'", GetName(playerid), time, GetName(playerid));
mysql_tquery(g_SQL, query);
}
if(!mysql_errno(g_SQL))
{
format(string, sizeof(string), "{FFFFFF}You are banned from this server\n{D93D3D}Username: {FFFFFF}%s\n{D93D3D}Banned by: {FFFFFF}%s\n{D93D3D}Ban Reason: {FFFFFF}%s\n{D93D3D}Date: {FFFFFF}%s", GetName(playerid), GetName(bannerid), reason, ReturnDate());
Dialog_Show(playerid, DIALOG_BANNED, DIALOG_STYLE_MSGBOX, "Ban Info", string, "Close", ""); // Show this dialog to the player.
DelayedKick(playerid);
}
else
{
SCM(bannerid, COLOR_RED, "Something wrong at ban query, please check the console");
printf("Query : %s", query);
}
}
CMD:tempban(playerid, params[])
{
if(pInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, -1, "SERVER: You are not authorized to use that command."); // If the player is not logged into rcon
if(BanToggle) return SCM(playerid, COLOR_LIGHTBLUE,"SERVER: {FFFFFF}That command is currently disabled, contact a level 4 to enable it.");
new PlayerIP[17];
new gpid, day, reason[128], time[26], ntime[30];
GetPlayerIp(gpid, PlayerIP, sizeof(PlayerIP)); // We are going to get the target's IP with this.
if(sscanf(params, "dds[128]S(No Reasons Given)[128]", gpid, day, time, reason)) return SendClientMessage(playerid, -1, "USAGE: /tempban [playerid] [time] [Sec/Min/Hour/Day/Week/Month/Year] [reason]"); // This will show the usage of the command after the player types /ban
else
{
if(strcmp(time, "Day", false) || strcmp(time, "Hour", false) || strcmp(time, "Min", false) || strcmp(time, "Week", false) || strcmp(time, "Sec", false) || strcmp(time, "Year", false) || strcmp(time, "Month", false))
{
strreplaceEx(time, "Sec", "SECOND", false, 30, 26); strreplaceEx(time, "sec", "SECOND", false, 30, 26);
strreplaceEx(time, "Min", "MINUTE", false, 30, 26); strreplaceEx(time, "min", "MINUTE", false, 30, 26);
strreplaceEx(time, "Hour", "HOUR", false, 30, 26); strreplaceEx(time, "hour", "HOUR", false, 30, 26);
strreplaceEx(time, "Day", "DAY", false, 30, 26); strreplaceEx(time, "day", "DAY", false, 30, 26);
strreplaceEx(time, "Week", "WEEK", false, 30, 26); strreplaceEx(time, "week", "WEEK", false, 30, 26);
strreplaceEx(time, "Month", "MONTH", false, 30, 26); strreplaceEx(time, "month", "MONTH", false, 30, 26);
strreplaceEx(time, "Year", "YEAR", false, 30, 26); strreplaceEx(time, "year", "YEAR", false, 30, 26);
if(!IsPlayerConnected(gpid)) return SendClientMessage(playerid, -1, "That player is not connected"); // If the target is not connected.
if(IsPlayerAdmin(gpid)) return SCM(playerid, COLOR_WHITE, "You can't ban Owner!");
if(pInfo[gpid][pAdmin] > pInfo[playerid][pAdmin]) return 0;
if(day > 0 && day < 1000)
{
format(ntime, sizeof(ntime), "'%d' %s", day, time);
BanPlayer(gpid, playerid, ntime, reason);
}
else SCM(playerid, COLOR_WHITE, "Time must between 1 - 999");
}
else cmd_tempban(playerid, "");
}
return 1;
}