public Plugin:myinfo = { name = "Wins Stat", author = "User", description = "", version = "1" , url = "" };
new Handle:g_SQL = INVALID_HANDLE, bool:MYSQL;
public OnPluginStart() { RegConsoleCmd("week", week); if (!SQL_CheckConfig("wins_stats")) { SetFailState("Секция \"wins_stats\" не найдена в databases.cfg"); return; }
decl String:error[256]; g_SQL = SQL_Connect("wins_stats", true, error, 256); if (g_SQL == INVALID_HANDLE) { LogError(error); SetFailState("Не удалось установить SQL соединение"); return; }
// тип соединения (mysql или sqlite) new String:driver[15]; SQL_ReadDriver(g_SQL, driver, 15); MYSQL = StrEqual(driver, "mysql", false); LogMessage("Установлено %s соединение", MYSQL ? "MYSQL" : "SQLite");
// Забираем данные if (!MYSQL) { SQL_TQuery(g_SQL, SQL_DefCallback, "SELECT id, week, name, steam_id, place, week_wins FROM wins ORDER BY place LIMIT 0, 10"); } }
public SQL_DefCallback(Handle:owner, Handle:hndl, const String:error[], any:data) { if (hndl == INVALID_HANDLE) LogError(error); } public Action:week(client, args) { if (client > 0 && args < 1) ShowMyPanel(client); return Plugin_Handled; }