CMD:oban(playerid, params[])// Banning offline players
{
new banned, AdminName[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME], str[128], reason[32], query[128], rows;
GetPlayerRPName(playerid, AdminName, sizeof(AdminName));
GetPlayerName(banned, PlayerName, sizeof(PlayerName));
if(PlayerInfo[playerid][Admin] > 3)
{
if(sscanf(params, "s[24]", PlayerName, reason)) return SendClientMessage(playerid, COLOR_DARKCORAL, "USAGE: /o(ffline)ban [Player NAME] [Reason]");
cache_get_row_count(rows);
if(rows > 0)
{
mysql_format(g_Sql, query, sizeof(query), "UPDATE `accounts` SET `isBanned` = 1 WHERE `Name` = '%e'", PlayerName);
mysql_tquery(g_Sql, query, "", "");
format(str, sizeof(str), "%s has offline banned %s. Reason: %s", AdminName, PlayerName, reason);
SendClientMessageToAll(COLOR_DARKCORAL, str);
}
else
{
SendClientMessage(playerid, COLOR_DARKCORAL, "That player doesn't exist!");
}
}
else
{
SendClientMessage(playerid, COLOR_DARKCORAL, "You cannot use this command!");
}
return 1;
}
CMD:oban(playerid, params[])// Banning offline players
{
new banned, AdminName[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME], str[128], reason[32], query[128];
GetPlayerRPName(playerid, AdminName, sizeof(AdminName));
GetPlayerName(banned, PlayerName, sizeof(PlayerName));
if(PlayerInfo[playerid][Admin] > 3)
{
if(sscanf(params, "s[24] s[24]", PlayerName, reason)) return SendClientMessage(playerid, COLOR_DARKCORAL, "[BS] {AFAFAF}USAGE: /o(ffline)ban [Player NAME] [Reason]");
mysql_format(g_Sql, query, sizeof(query), "SELECT * FROM `accounts` WHERE `Name` = '%e' LIMIT 1", PlayerName);
mysql_tquery(g_Sql, query, "OffBan", "is", playerid, PlayerName);
printf(query);
format(str, sizeof(str), "[BS] {AA3333} %s has offline banned %s. Reason: %s", AdminName, PlayerName, reason);
SendClientMessageToAll(COLOR_DARKCORAL, str);
}
else
{
SendClientMessage(playerid, COLOR_DARKCORAL, "[BS] {AFAFAF}You cannot use this command!");
}
return 1;
}
forward OffBan(playerid, Banned);
public OffBan(playerid, Banned)
{
new rows, fields, query[128], isOBanned = 0;
cache_get_row_count(rows);
cache_get_field_count(fields);
if(rows)
{
cache_get_value_name_int(0, "isBanned", isOBanned);
if(isOBanned == 1)
{
SendClientMessage(playerid, COLOR_DARKCORAL, "[BS] {AFAFAF}That player is already banned!");
return 1;
}
mysql_format(g_Sql, query, sizeof(query), "UPDATE `accounts` SET `isBanned` = 1 WHERE `Name` = %e", Banned);
mysql_tquery(g_Sql, query, "", "");
printf(query);
}
else if(!rows)
{
SendClientMessage(playerid, COLOR_DARKCORAL, "[BS] {AFAFAF}That player doesn't exist!");
return 1;
}
return 1;
}
WHERE `Name` = '%e'
// In your oban cmd mysql_format(g_Sql, query, sizeof(query), "UPDATE `accounts` SET `isBanned` = 1 WHERE `Name` = '%e'", PlayerName); mysql_tquery(g_Sql, query, "OffBan", "is", playerid, PlayerName); public OffBan(playerid, Banned[]) { if(cache_affected_rows()) // It returns total of affected rows { new fmt[128]; format(fmt, 128, "[BS] {AFAFAF}You have offline banned %s", Banned); SendClientMessage(playerid, COLOR_DARKCORAL, "[BS] {AFAFAF}Offline ban executed!"); return 1; } else { SendClientMessage(playerid, COLOR_DARKCORAL, "[BS] {AFAFAF}That player doesn't exist or already banned!"); return 1; } return 1; }
public OffBan(playerid, Banned[])
Second parameter of "OffBan" callback is integer, it should be an array/string.
Код:
public OffBan(playerid, Banned[]) |