- Автор темы
- #1
Когда банишь то не записывается бан в базу данных помогите пожалуйста
Команда
CMD:ban(playerid, params[])
{
if(GetPlayerAdminEx(playerid) < 3) return 1;
if(!strlen(params)) return SendClientMessage(playerid, 0xCECECEFF, "Èñïîëüçóéòå: /ban [ID èãðîêà] [ñðîê â äíÿé èëè -1] [ïðè÷èíà (íåîáÿçàòåëüíî)]");
extract params -> new to_player, ban_time, string:reason[30];
if(!IsPlayerConnected(to_player) || !IsPlayerLogged(to_player))
return SendClientMessage(playerid, 0xCECECEFF, "Òàêîãî èãðîêà íåò");
if(!(-1 <= ban_time <= 365) || ban_time == 0) return SendClientMessage(playerid, 0xFF6600FF, "Cðîê áàíà îò 1 äî 365 èëè -1");
if(GetPlayerAdminEx(to_player) > GetPlayerAdminEx(playerid))
return SendClientMessage(playerid, 0xCECECEFF, "Íåëüçÿ çàáàíèòü àäìèíèñòðàòîðà âûøå Âàñ ïî ðàíãó");
new fmt_text[100];
if(ban_time != -1)
format(fmt_text, sizeof fmt_text, "Àäìèíèñòðàòîð %s çàáàíèë èãðîêà %s íà %d äíåé. Ïðè÷èíà: %s", GetPlayerNameEx(playerid), GetPlayerNameEx(to_player), ban_time, reason);
else
format(fmt_text, sizeof fmt_text, "Àäìèíèñòðàòîð %s íàâñåãäà çàáàíèë èãðîêà %s. Ïðè÷èíà: %s", GetPlayerNameEx(playerid), GetPlayerNameEx(to_player), reason);
SendClientMessageToAll(0xFF5533FF, fmt_text);
new query[344];
new message[324];
new days[24];
if(ban_time != -1)
{
format(days, sizeof days, "%d äíåé", ban_time);
}
else
{
format(days, sizeof days, "Íàâñåãäà");
}
new year, month, day;
getdate(year, month, day);
format(message, sizeof message, "{"#cW"}Äàòà: %d %s %d ã.\nÂàø íèê: %s\nÍèê àäìèíèñòðàòîðà: %s\nÊîëè÷åñòâî äíåé: %s\nÏðè÷èíà: %s\n\nÅñëè Âû íå ñîãëàñíû ñ íàêàçàíèåì, ñäåëàéòå ñêðèíøîò (F8)\nÈ îñòàâüòå æàëîáó íà ôîðóìå {"#cGold"}"SERVER_SITE"",
day,
GetMonthName(month),
year,
GetPlayerNameEx(to_player), GetPlayerNameEx(playerid), days, reason);
Dialog(to_player, INVALID_DIALOG_ID, DIALOG_STYLE_MSGBOX, "{FF6600}Áëîêèðîâêà àêêàóíòà", message, "Çàêðûòü", "");
SetPlayerData(to_player, P_ADMIN, 0);
UpdatePlayerDatabaseInt(to_player, "admin", 0);
mysql_format(mysql, query, sizeof query, "UPDATE admin SET bans = bans+1 WHERE name = '%s'", GetPlayerNameEx(playerid));
mysql_query(mysql, query, false);
AddBan(GetPlayerAccountID(to_player), gettime(), ban_time, GetPlayerIpEx(to_player), reason, GetPlayerNameEx(playerid), GetPlayerNameEx(to_player));
SetTimerEx("DelayedKick", 200, false, "i", playerid);
mysql_format(mysql, query, sizeof query, "INSERT INTO alogs (acc_id,type,name_adm,name,time,reason) VALUES (%d,'%e','%e',%d,'%e')", GetPlayerAccountID(to_player), "Áàí", GetPlayerNameEx(playerid), GetPlayerNameEx(to_player), gettime(), reason);
mysql_query(mysql, query, false);
return 1;
}
сток addban который должен заносить бан в базу данных mysql
stock AddBan(user_id, time, days, ip[], description[], admin_name[], name[])
{
new query[200];
new c_time = time-(time % 86400);
mysql_format(mysql, query, sizeof query, "INSERT INTO ban_list (user_id,time,ban_time,ip,description,admin,name) VALUES (%d,%d,%d,'%e','%e','%e','%e')", user_id, c_time, c_time + (days * 86400), ip, description, admin_name, name);
mysql_query(mysql, query, false);
return !mysql_errno();
}
Команда
CMD:ban(playerid, params[])
{
if(GetPlayerAdminEx(playerid) < 3) return 1;
if(!strlen(params)) return SendClientMessage(playerid, 0xCECECEFF, "Èñïîëüçóéòå: /ban [ID èãðîêà] [ñðîê â äíÿé èëè -1] [ïðè÷èíà (íåîáÿçàòåëüíî)]");
extract params -> new to_player, ban_time, string:reason[30];
if(!IsPlayerConnected(to_player) || !IsPlayerLogged(to_player))
return SendClientMessage(playerid, 0xCECECEFF, "Òàêîãî èãðîêà íåò");
if(!(-1 <= ban_time <= 365) || ban_time == 0) return SendClientMessage(playerid, 0xFF6600FF, "Cðîê áàíà îò 1 äî 365 èëè -1");
if(GetPlayerAdminEx(to_player) > GetPlayerAdminEx(playerid))
return SendClientMessage(playerid, 0xCECECEFF, "Íåëüçÿ çàáàíèòü àäìèíèñòðàòîðà âûøå Âàñ ïî ðàíãó");
new fmt_text[100];
if(ban_time != -1)
format(fmt_text, sizeof fmt_text, "Àäìèíèñòðàòîð %s çàáàíèë èãðîêà %s íà %d äíåé. Ïðè÷èíà: %s", GetPlayerNameEx(playerid), GetPlayerNameEx(to_player), ban_time, reason);
else
format(fmt_text, sizeof fmt_text, "Àäìèíèñòðàòîð %s íàâñåãäà çàáàíèë èãðîêà %s. Ïðè÷èíà: %s", GetPlayerNameEx(playerid), GetPlayerNameEx(to_player), reason);
SendClientMessageToAll(0xFF5533FF, fmt_text);
new query[344];
new message[324];
new days[24];
if(ban_time != -1)
{
format(days, sizeof days, "%d äíåé", ban_time);
}
else
{
format(days, sizeof days, "Íàâñåãäà");
}
new year, month, day;
getdate(year, month, day);
format(message, sizeof message, "{"#cW"}Äàòà: %d %s %d ã.\nÂàø íèê: %s\nÍèê àäìèíèñòðàòîðà: %s\nÊîëè÷åñòâî äíåé: %s\nÏðè÷èíà: %s\n\nÅñëè Âû íå ñîãëàñíû ñ íàêàçàíèåì, ñäåëàéòå ñêðèíøîò (F8)\nÈ îñòàâüòå æàëîáó íà ôîðóìå {"#cGold"}"SERVER_SITE"",
day,
GetMonthName(month),
year,
GetPlayerNameEx(to_player), GetPlayerNameEx(playerid), days, reason);
Dialog(to_player, INVALID_DIALOG_ID, DIALOG_STYLE_MSGBOX, "{FF6600}Áëîêèðîâêà àêêàóíòà", message, "Çàêðûòü", "");
SetPlayerData(to_player, P_ADMIN, 0);
UpdatePlayerDatabaseInt(to_player, "admin", 0);
mysql_format(mysql, query, sizeof query, "UPDATE admin SET bans = bans+1 WHERE name = '%s'", GetPlayerNameEx(playerid));
mysql_query(mysql, query, false);
AddBan(GetPlayerAccountID(to_player), gettime(), ban_time, GetPlayerIpEx(to_player), reason, GetPlayerNameEx(playerid), GetPlayerNameEx(to_player));
SetTimerEx("DelayedKick", 200, false, "i", playerid);
mysql_format(mysql, query, sizeof query, "INSERT INTO alogs (acc_id,type,name_adm,name,time,reason) VALUES (%d,'%e','%e',%d,'%e')", GetPlayerAccountID(to_player), "Áàí", GetPlayerNameEx(playerid), GetPlayerNameEx(to_player), gettime(), reason);
mysql_query(mysql, query, false);
return 1;
}
сток addban который должен заносить бан в базу данных mysql
stock AddBan(user_id, time, days, ip[], description[], admin_name[], name[])
{
new query[200];
new c_time = time-(time % 86400);
mysql_format(mysql, query, sizeof query, "INSERT INTO ban_list (user_id,time,ban_time,ip,description,admin,name) VALUES (%d,%d,%d,'%e','%e','%e','%e')", user_id, c_time, c_time + (days * 86400), ip, description, admin_name, name);
mysql_query(mysql, query, false);
return !mysql_errno();
}