24.10.2014, 19:23
Help
Код:
#include <a_samp> #include <sscanf2> #define DIALOG_BANLIST 500 // Ваш ID диалога банлиста #define DIALOG_UNBAN 501 // Ваш ID диалога разбана new DB:ServerDB, year, month, day, UBDay, UBHour, UBMin, UBSec, UBMSec, bool:plban[MAX_PLAYERS], sendername[32], giveplayer[32], stra[255], player[MAX_PLAYERS]; public OnFilterScriptInit() { if(fexist("bans.db")) ServerDB = db_open("bans.db"); else { ServerDB = db_open("bans.db"); db_query(ServerDB, "CREATE TABLE bans (name varchar, ip varchar, bandate varchar, time int, unbandate int, reason varchar)"); } SetTimer("CheckBans", 1000, 1); return true; } public OnPlayerConnect(playerid) { CheckBanList(playerid); return true; } public OnPlayerDisconnect(playerid) { plban[playerid] = false; player[playerid] = 0; return true; } public OnPlayerCommandText(playerid, cmdtext[]) { new cmd[32], params[128]; sscanf(cmdtext, "ss", cmd, params); if(!strcmp(cmd, "/ban", true)) { if(!IsPlayerAdmin(playerid)) return true; new giveplayerid, days, text[255], ip[32], date[32], unbandate; if(sscanf(params, "uds[255]", giveplayerid, days, text)) return SendClientMessage(playerid, 0xFF0000AA, "{FFFF00}*Подсказка*: {FFFFFF}/ban [ID игрока] [Кол-во дней] [Причина]"); if(!IsPlayerConnected(giveplayerid) || giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000AA, "{FFFF00}*Внимание*: {FFFFFF}данный игрок не в сети"); GetPlayerName(playerid, sendername, 32); GetPlayerName(giveplayerid, giveplayer, 32); GetPlayerIp(giveplayerid, ip, 32); format(stra, sizeof(stra), "{FFFF00}* {%06x}%s(%d) {00FF00}забанен администрацией сервера. {BF00FF}Срок бана в днях: {FFFFFF}%d. {BF00FF}Причина: {FFFFFF}%s {FFFF00}*", GetPlayerColor(giveplayerid) >>> 8, giveplayer, giveplayerid, days, text); SendClientMessageToAll(0xFF0000AA, stra); plban[giveplayerid] = true; unbandate = gettime() + days*86400; format(date, 32, "%02d.%02d.%04d", day, month, year); format(stra, sizeof(stra), "INSERT INTO bans (name, ip, bandate, time, unbandate, reason) VALUES ('%s', '%s', '%s', %d, %d, '%s')", giveplayer, ip, date, days, unbandate, text); db_query(ServerDB, stra); return true; } if(!strcmp(cmd, "/unban", true)) { if(!IsPlayerAdmin(playerid)) return true; new text[32], DBResult:answer; if(sscanf(params, "s", text)) return SendClientMessage(playerid, 0xFF0000AA, "{FFFF00}*Подсказка*: {FFFFFF}/unban [ID игрока]"); format(stra, sizeof(stra), "SELECT * FROM bans WHERE name = '%s'", text); answer = db_query(ServerDB, stra); if(!db_num_rows(answer)) return SendClientMessage(playerid, 0xFF0000AA, "{FFFF00}*Внимание*: {FFFFFF}Данного игрока нет в бан листе!"); format(stra, sizeof(stra), "DELETE FROM bans WHERE name = '%s'", text); db_query(ServerDB, stra); format(stra, sizeof(stra), "{00FF00}Вы разбанили {FFFFFF}%s", text); SendClientMessage(playerid, 0xFF0000AA, stra); db_free_result(answer); return true; } if(!strcmp(cmd, "/banlist", true)) { if(!IsPlayerAdmin(playerid)) return true; new DBResult:answer, rows, banlist[1000]; new name[32], ip[32]; answer = db_query(ServerDB, "SELECT name, ip FROM bans"); rows = db_num_rows(answer); for(new i; i<rows; i++) { db_get_field(answer, 0, name, 32); db_get_field(answer, 1, ip, 32); format(stra, sizeof(stra), "{FF0000}%s {FFFF00}(%s)\n", name, ip); strcat(banlist, stra); db_next_row(answer); } ShowPlayerDialog(playerid, DIALOG_BANLIST, DIALOG_STYLE_LIST, "БанЛист", banlist, "Выбрать", "Закрыть"); db_free_result(answer); return true; } if(!strcmp(cmd, "/cbanlist", true)) { if(!IsPlayerAdmin(playerid)) return true; format(stra, sizeof(stra), "DELETE FROM bans WHERE unbandate < %d", getdate()); db_query(ServerDB, stra); SendClientMessage(playerid, 0xFF0000AA, "Чистка выполнена"); return true; } return 0; } stock convert(time, &min, &sec, &msec) { new Float:fTime = floatdiv(time, 60000); min = floatround(fTime, floatround_tozero); sec = floatround(floatmul(fTime - min, 60), floatround_tozero); msec = floatround(floatmul(floatmul(fTime - min, 60) - sec, 1000), floatround_tozero); } stock CheckBanList(playerid) { new DBResult:answer, var[32], unbandate, bool:ban, ip[32]; GetPlayerName(playerid, sendername, 32); GetPlayerIp(playerid, ip, 32); format(stra, sizeof(stra), "SELECT * FROM bans WHERE name = '%s'", sendername); answer = db_query(ServerDB, stra); if(db_num_rows(answer)) { db_get_field(answer, 4, var, 32); unbandate = strval(var); if(unbandate - gettime() > 0) ban = true; } if(!ban) { format(stra, sizeof(stra), "SELECT * FROM bans WHERE ip = '%s'", ip); answer = db_query(ServerDB, stra); if(db_num_rows(answer)) { db_get_field(answer, 4, var, 32); unbandate = strval(var); if(unbandate - gettime() > 0) ban = true; } } if(ban) { convert((unbandate-gettime())*1000,UBMin,UBSec,UBMSec); UBHour = UBMin/60; UBMin = UBMin%60; UBDay = UBHour/24; UBHour = UBHour%24; format(stra, sizeof(stra), "{FF0000}Ваш аккаунт заблокирован! {FFFF00}До разбана осталось {FFFFFF}%d дней %d часов %d минут {FFFF00}и {FFFFFF}%d секунд", UBDay, UBHour, UBMin, UBSec); SendClientMessage(playerid, 0xFF0000FF, stra); Kick(playerid); } return true; } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if(dialogid == DIALOG_BANLIST && response) { new dialog[500], DBResult:answer, name[32], ip[32], bandate[32], time, unbandate, reason[255], var[32]; answer = db_query(ServerDB, "SELECT * FROM bans"); for(new i; i<listitem; i++) db_next_row(answer); db_get_field(answer, 0, name, 32); db_get_field(answer, 1, ip, 32); db_get_field(answer, 2, bandate, 32); db_get_field(answer, 3, var, 32); time = strval(var); db_get_field(answer, 4, var, 32); unbandate = strval(var); db_get_field(answer, 5, reason, 255); player[playerid] = listitem; convert((unbandate-gettime())*1000,UBMin,UBSec,UBMSec); UBHour = UBMin/60; UBMin = UBMin%60; UBDay = UBHour/24; UBHour = UBHour%24; format(stra, sizeof(stra), "{FFFF00}Ник: {FFFFFF}%s. {FFFF00}IP: {FFFFFF}%s\n", name, ip); strcat(dialog, stra); format(stra, sizeof(stra), "{FFFF00}Дата бана: {FFFFFF}%s\n", bandate); strcat(dialog, stra); format(stra, sizeof(stra), "{FFFF00}Срок бана: {FFFFFF}%d\n", time); strcat(dialog, stra); format(stra, sizeof(stra), "{FFFF00}Разбан через: {FFFFFF}%d дней и %d часов\n", UBDay, UBHour); strcat(dialog, stra); format(stra, sizeof(stra), "{FFFF00}Причина бана: {FFFFFF}%s", reason); strcat(dialog, stra); ShowPlayerDialog(playerid, DIALOG_UNBAN, DIALOG_STYLE_MSGBOX, "БанЛист", dialog, "Закрыть", "Разбанить"); db_free_result(answer); return true; } if(dialogid == DIALOG_UNBAN && !response) { new DBResult:answer, name[32]; answer = db_query(ServerDB, "SELECT name FROM bans"); for(new i; i<player[playerid]; i++) db_next_row(answer); db_get_field(answer, 0, name, 32); format(stra, sizeof(stra), "DELETE FROM bans WHERE name = '%s'", name); db_query(ServerDB, stra); SendClientMessage(playerid, 0xFF0000AA, "Аккаунт разблокирован!"); db_free_result(answer); return true; } return false; } forward CheckBans(); public CheckBans() { for(new i; i<GetMaxPlayers(); i++) { if(IsPlayerConnected(i) && plban[i] == true) Kick(i); } return true; }
Код:
\pawno\include\sscanf2.inc(227) : warning 202: number of arguments does not match definition \pawno\include\sscanf2.inc(240) : error 025: function heading differs from prototype Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 1 Error.