1 /* cmd_neonserv_listrank.c - NeonServ v5.0
2 * Copyright (C) 2011 Philipp Kreil (pk910)
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include "cmd_neonserv.h"
24 CMD_BIND(neonserv_cmd_listrank) {
25 MYSQL_RES *res, *res2;
29 printf_mysql_query("SELECT `rank_id`, `rank_name` FROM `support_ranks` ORDER BY `rank_order` ASC");
31 table = table_init(3, mysql_num_rows(res) + 1, 0);
33 content[0] = get_language_string(user, "NS_LISTRANK_ID");
34 content[1] = get_language_string(user, "NS_LISTRANK_NAME");
35 content[2] = get_language_string(user, "NS_LISTRANK_ASSIGNED");
36 table_add(table, content);
37 while ((row = mysql_fetch_row(res)) != NULL) {
41 printf_mysql_query("SELECT COUNT(*) FROM `users` WHERE `user_rank` = '%s'", row[0]);
43 row = mysql_fetch_row(res2);
45 table_add(table, content);
48 char **table_lines = table_end(table);
50 for(i = 0; i < table->entrys; i++) {
51 reply(getTextBot(), user, table_lines[i]);
54 reply(getTextBot(), user, "NS_TABLE_NONE");
56 printf_mysql_query("SELECT COUNT(*) FROM `users` WHERE `user_rank` = '0' AND `user_access` > 0");
58 row = mysql_fetch_row(res2);
59 reply(getTextBot(), user, "NS_LISTRANK_UNRANKED", atoi(row[0]));